JS Minifier
Powered by Terser with real syntax analysis — the output is valid code, not text substitution.
- Paste your JavaScript into the input field.
- Minification runs automatically after a short pause in typing.
- The result shows the original size, the final size and the percentage saved.
- If the code has a syntax error, the parser message appears instead of broken output.
This tool runs Terser, the same engine used in production builds across much of the JavaScript ecosystem. It parses the syntax rather than applying text substitutions.
Beyond stripping comments and whitespace, it shortens local variable and parameter names, removes unreachable code and folds constant expressions. Adding 1 and 2 simply becomes 3 in the output.
Exported names and object properties are left alone, because something outside the file may depend on them.
Minifying JavaScript with regular expressions cannot be done correctly. A slash may be division, the start of a regular expression or the start of a comment, and only parsing tells them apart.
The nastiest case is automatic semicolon insertion: code written without semicolons relies on line breaks. A minifier that collapses whitespace without understanding the code merges two statements onto one line and produces a syntax error.
The same applies to quoted content: spaces inside a string are data, not formatting, and must never be touched.
Everything runs in your browser. Pasted code is never sent to a server or logged, which makes the tool safe for proprietary code.
Terser is downloaded only when you open this page, so it does not weigh on the rest of the site.
Very large files may briefly tie up the interface, since parsing runs on the same thread as the page.
Frequently asked questions
With real parsing it should not. When output does fail, the usual cause is code that depends on function names at runtime — through reflection or names printed in logs — since mangling shortens them.
Minifying rewrites the code so it takes fewer characters. Compression, with gzip or brotli, happens in transit and is undone by the browser. The two stack.
Not exactly. Original names and comments are gone. You can re-indent the result to read it, but the removed information does not come back — always keep the source.
The parser found something invalid before minifying. The message points at the position. Very new syntax, or TypeScript and JSX, is not recognised — minify already-compiled JavaScript.
No. Minification happens entirely in your browser.