Minify JavaScript with Terser — stripping comments and whitespace, shortening local variable names and simplifying expressions — or beautify minified code back into readable form. Because Terser is a real parser, modern syntax like arrow functions, classes and optional chaining is handled correctly, and a syntax error gives a clear message instead of broken output.
Minify vs. Beautify
Minify shrinks your JavaScript to the smallest working size — stripping comments and whitespace, shortening local variable names, and simplifying expressions. It's powered by Terser, a real JavaScript parser, so modern syntax (arrow functions, template literals, classes, optional chaining) is handled correctly rather than broken by a naive text replace; if your code has a syntax error you'll get a clear message pointing at it. Beautify does the reverse, re-indenting minified or messy code so it's readable again.
How to use the JavaScript Minifier
- Paste — paste the JavaScript you want to minify or beautify into the input box above.
- Choose indentation — pick 2 spaces, 4 spaces, or a tab (this applies only to Beautify output; it has no effect on Minify).
- Run — press the "Minify" or "Beautify" button. The first time you minify, the Terser library is downloaded once and then runs.
- Copy — check the size read-out and use the "Copy" button to put the result on your clipboard.
Is modern syntax (arrow functions, classes, etc.) minified safely?
Yes. Minifying is performed by Terser, a real JavaScript parser, so modern ES syntax like arrow functions, template literals, classes, optional chaining, and destructuring is understood and handled correctly. Regex literals, comment-looking text inside strings, and other things a naive text-replace would break are preserved intact.
Does minifying change how my code behaves?
No. Terser only performs transformations that preserve your code's behavior — shortening local variable names, removing dead code, and simplifying expressions are all done safely so the result is identical. That said, identifiers exposed to the outside world, such as global variable or function names, are not renamed, because other code may reference them.
What happens if there's a syntax error?
Because Terser actually parses your code, if there's a syntax error — a mismatched bracket, an invalid token — it stops minifying and shows a clear error message pointing to where the problem is (line and column). Instead of silently producing a wrong result, it tells you where to fix, so you can correct the spot it points to and try again.
Is my code uploaded? Why the short pause on first minify?
Nothing is uploaded — everything runs in your browser. The Terser minifier is a large library, so to keep this page loading fast it's fetched only the first time you press Minify (you may see a brief "Minifying…" pause once); after that it's cached. Beautify is instant. When you're done, the size read-out shows how many bytes minifying saved, and Copy puts the result on your clipboard.