JavaScript Minifier
Compress JavaScript by removing whitespace and shortening names.
JavaScript is the most expensive resource on most pages. It is not just the download — the browser has to parse, compile and execute it, and on a mid-range phone that work costs far more than the transfer did.
Minifying JavaScript
- Paste your JavaScript into the box above.
- Minify it.
- Copy the compressed output.
- Test it properly, because minification bugs are subtle.
- Deploy the minified file and keep the source, plus a source map.
How JS minification goes further than CSS
A CSS minifier removes whitespace. A JavaScript minifier does that and then renames things: local variables and function parameters get shortened to single letters, because nothing outside the function can see those names.
That is where the real savings come from — a descriptive name like calculateTotalPrice becomes t. Typical reductions land around 30–50% before compression, considerably more than you get from whitespace removal alone.
Things minification can break
- Code that reads
Function.prototype.nameor a constructor name at runtime. - Dependency injection that relies on parameter names, as older AngularJS did.
- Anything using
evalwith dynamically constructed variable names. - Reflection over object properties that a mangler decided to rename.
- Implicit semicolon insertion edge cases in code that was already fragile.
Always ship a source map
A minified stack trace tells you an error happened at line 1, column 24,000, which is useless. A source map lets your browser and your error tracker translate that back to the original file and line.
Generate one during the build and either serve it or upload it to your monitoring tool. Debugging production without one is guesswork.
JavaScript minification questions
How much smaller does minified JavaScript get?
Typically 30–50% before compression, because variable renaming removes far more than whitespace alone. With gzip or Brotli on top, the transferred size drops further still.
What is the difference between minification and obfuscation?
Minification optimises for size and keeps the code functionally transparent. Obfuscation deliberately makes it hard to understand, usually at the cost of a larger file and slower execution. They are different goals.
Can minified JavaScript be reversed?
The structure can be recovered by a formatter, but the original variable and function names are gone for good. That is a side effect, not a security measure — anything shipped to a browser is readable.
Does minification break my code?
Rarely, but it can when code depends on function or parameter names at runtime. Test the minified bundle rather than assuming it behaves identically.
Should I minify by hand?
No. Put it in your build pipeline with a tool like esbuild, Terser or SWC, keep readable source in version control, and generate source maps automatically.