JavaScript Minifier
Minify and compress JavaScript with Terser — 100% in your browser, no upload
Enter some JavaScript, then click Minify.
🔒 Minified in your browser with Terser — nothing is uploaded.
Minify JavaScript instantly
Paste your JavaScript and this tool runs it through Terser — the same compressor bundlers like Rollup and Vite rely on — to strip comments, collapse whitespace, drop dead code, and optionally shorten local variable names. The result is smaller, faster-loading code you can drop straight into production.
Private by design
Minification happens entirely in your browser; your source code is never uploaded to a server, so it is safe to minify proprietary or unreleased code.
Minifying, compressing and obfuscating are three different things
Minifying rewrites the source into an equivalent, smaller one: whitespace and comments go, local names shrink to a letter or two, dead branches are dropped. Compressing — gzip or brotli, applied by the server on the way out — finds repetition in whatever bytes it is given. They stack, but not additively: minified code compresses less well than the original did, because minifying already removed the repetition gzip was feeding on, so a 60% minify plus a 70% gzip is not 88%. Obfuscating is a third thing, aimed at making code hard to read rather than small, and it usually makes the file bigger.
What a minifier can and cannot know
Renaming is safe for locals because the tool can see every use. It is not safe for anything reached by name from outside — a property looked up as obj[key] with the key built at runtime, a function called from an inline onclick, an export another bundle imports. A minifier leaves those alone, which is why minified output still contains readable property names. The transform is behaviour-preserving by design and the source map is what gets a stack trace back to real line numbers; keep one, and serve it somewhere your error reporter can read it but the public cannot.
Frequently asked questions
What does "mangle names" do?
Mangling renames local variables and function parameters to short single letters (for example, salutationTarget becomes n) to shrink the output further. Top-level and exported names are left intact so your public API keeps working. Turn it off if you need readable variable names.
Does minifying change how my code behaves?
No. Terser only removes things that do not affect execution — whitespace, comments, unreachable code — and safely renames locals. If your input has a syntax error, the tool shows the error instead of producing broken output.
Should I minify if the server already gzips?
Yes, but expect less than the two numbers suggest. Minifying and compressing both exploit redundancy, so the second one finds less after the first has run. Together they still beat either alone.
Will minifying break my code?
It should not — the transform preserves behaviour. The usual breakages come from things the tool cannot see: names resolved as strings at runtime, functions called from inline HTML attributes, or code relying on Function.prototype.name.
Why are some names still readable afterwards?
Only local bindings can be renamed safely. Property names, globals and exports may be reached from code the minifier has never seen, so they are left as they are.