JavaScript Minifier
Compress JavaScript with real Terser mangling and dead-code removal, or beautify minified code back to readable form. Everything runs in your browser.
Real minification, not just whitespace
Stripping spaces and newlines is the easy part. This tool runs your code through Terser, a proper JavaScript compressor, so it also shortens local variable names, folds constants, and removes unreachable branches. The result is meaningfully smaller than a whitespace-only pass, which is why the exact byte count and percentage saved appear above every time.
The options explained
- Mangle names renames local variables and parameters to single letters. This is where most of the size saving comes from. Turn it off to keep your original names.
- Keep function names preserves the names of functions even while mangling
everything else, which matters if your code relies on
fn.nameor shows function names in stack traces. - Remove console statements deletes
consolecalls so debug logging never ships to production. - Mangle top-level names treats module-level names as private and can drop anything unused. Only enable it for self-contained files, never for a script that exposes globals.
A note on secrets and source maps
Nothing you paste here leaves your browser, so private code is safe. Even so, make it a rule never to paste live API keys, passwords or tokens into any online tool. This tool does not generate a source map; if you need to debug minified code, produce maps in your build step instead. To restore a compressed file to a readable state, switch to Beautify, which re-indents it with the spacing you choose.
Working across formats? Pair this with the HTML formatter, the CSS minifier or the JSON formatter.