Minify JS

Shrink JavaScript with Terser, right in your browser.

This free online JavaScript minifier strips comments and whitespace, shortens variable names, and simplifies your code — with a live before/after size comparison. No signup, runs entirely in your browser.

Compress

Rewrites the code to be shorter — dead code removal, expression simplification.

Mangle

Renames local variables and parameters to short names.

Original
Minified

JavaScript Input
Minified

Loading minifier…

What does minifying JavaScript do?

Minifying JavaScript shrinks the file size without changing what the code does — stripping comments and whitespace, shortening variable names, and simplifying expressions. Smaller JS files download and parse faster, which is why production websites almost always ship minified code instead of the readable source.

Compress vs Mangle

Compress restructures the code itself — removing unreachable code, folding constant expressions, simplifying conditionals — changes that make the logic shorter without changing behavior. Mangle is purely cosmetic: it renames local variables and function parameters to short names like a, b, c. Both are usually left on for production builds; turning mangle off can help when you're debugging minified output and want variable names to stay recognizable.

Why minify instead of just gzip

Gzip compression (which most servers apply automatically) already removes a lot of redundancy from repeated whitespace and identifiers — but minifying first still helps, because a minifier understands JavaScript syntax and can safely delete things gzip can't touch, like comments, dead code, and unnecessary parentheses. Minify-then-gzip consistently produces smaller output than gzip alone.

Terser

Terser is the actively maintained successor to UglifyJS, built to understand modern ECMAScript syntax (arrow functions, classes, destructuring, and more) that UglifyJS predates. It's the minifier bundled inside most modern JavaScript build tools, so the output here matches what a typical production build pipeline would produce.

Frequently asked questions

How do I minify JavaScript?

Paste your JavaScript into the input — the minified result and the size reduction appear automatically. Toggle Mangle and Compress to control how aggressive the minification is.

What minifier does this use?

Terser — a widely used, actively maintained JavaScript minifier (the successor to UglifyJS for modern ES syntax), running entirely client-side.

What's the difference between Mangle and Compress?

Compress rewrites the code's structure to be shorter — removing dead code, simplifying expressions, inlining where safe. Mangle renames local variables and function parameters to short single-letter names. Both are on by default and can be combined; turning either off produces a larger but sometimes easier-to-debug output.

Is my code sent to a server?

No. Minification runs locally in your browser via Terser's client-side build — nothing you paste is ever sent anywhere.

Related tools: JavaScript Formatter · JSON Formatter · HTML Formatter