JavaScript Minifier
Minify JavaScript with Terser in your browser: compress code, mangle variable names and see the size saved. Shows parse errors. Free.
About JavaScript Minifier
The JavaScript Minifier shrinks your scripts with Terser, the widely used JavaScript compressor. Paste code, choose your options and copy the smaller version with the saving shown.
Mangle and compress
Mangle shortens variable names. Compress removes unused code and simplifies expressions. Together they give the smallest file.
Modern JavaScript
Nullish coalescing, private class fields, arrow functions, spread and modules are supported.
Clear errors
Invalid code shows the error with its line and column.
When to be careful
Code that relies on function names, eval or reading function source can break after mangling. Test the minified script.
Good for
Quick one-off minification, bookmarklets and learning what Terser does.
Private
The code is minified in your browser. It is not run or uploaded.
Example
function add(first, second) { return first + second; } can shrink to something like function add(n,d){return n+d} once names are mangled.
How to use JavaScript Minifier
- Paste your JavaScript.
- Choose whether to mangle variable names and compress the code.
- Press Minify.
- Copy the result or download it.
Related guide: Speed Up Your Website: Minify CSS, JavaScript and HTML
Help & FAQ
What does the JavaScript Minifier do?
It runs Terser on your code to remove white space and comments and, if you choose, to compress it and shorten variable names.
What does Mangle variable names do?
It renames local variables and parameters to short names such as e and n. In the test it cut a sample from 154 B to 100 B.
What does Compress do?
It rewrites code to be shorter, for example joining console.log and return with a comma. Turn it off if you want statements kept separate.
Are top-level names renamed?
No. In the test addNumbers and unused kept their names, so scripts that other files call keep working.
Does it support modern JavaScript?
Yes. The tests accepted ??, private class fields, spread, arrow functions, import, export, dynamic import and template literals.
Why can the result be bigger than the input?
Very short code has little to remove. A small snippet using import() grew from 26 B to 29 B in the test.
What does an error look like?
It shows Could not minify with the reason and the line and column, for example Unexpected token: punc (() (line 1, column 9).
Why did top-level await fail?
The code is read as a script, not as a module. Wrap it in an async function or use a build tool.
Can minifying break our code?
Rarely, but code that relies on function names, eval or reading parameter names can break. Always test the minified version.
Does it make a source map?
No. Keep your original file for debugging.
Is our code executed?
No. The page says the code is only parsed. It is not run.
Is our code uploaded?
No. Terser runs in your browser and the code is not sent to a server.