This strips comments and extra whitespace out of JavaScript so it takes fewer bytes. It understands strings, template literals and regular expressions, so those are never touched, and by default it keeps any line break that could change how the code runs, which matters if your code relies on automatic semicolon insertion. It doesn't rename variables, so it's a light-touch minifier rather than a replacement for a build tool.
How to use it
- Paste your JavaScript.
- Keep the line-break option on unless you're sure every statement ends in a semicolon.
- Check the before and after sizes.
- Copy the result.
When it helps
- Shrinking a small script or bookmarklet.
- Seeing how much of a file is comments and whitespace.
- Quick minification when you don't have a build step.
- Preparing a snippet to embed.
Good to know
- For production sites, a full build tool will compress further by shortening names.
- Always test minified code before deploying.
- Comments, including licence notices, are removed, so keep them elsewhere if you need them.
What gets removed
The minifier deletes comments and collapses runs of whitespace. It keeps a single space only where two identifier characters would otherwise merge, such as between return and a variable, and it preserves strings, template literals and regular expressions exactly.
By default it also keeps line breaks that might matter. JavaScript inserts semicolons automatically in certain cases, so removing every line break can change the meaning of code that omits them.
Worked example: a small function
A function with a comment, four lines of body and generous indentation shrinks to a single line with no comments, typically saving 30 to 50 percent. The before and after sizes are shown so you can see the saving.
Run the result in the browser console to check it works before you deploy it.
Minifying versus bundling and compressing
Production sites combine three things: bundling merges files, minifying shrinks them, and compression such as gzip or Brotli shrinks them again in transit. Minification helps, but gzip does much of the same job for repetitive whitespace.
A full minifier also shortens variable names, which saves more, but needs a parser. For serious projects, use a tool such as esbuild or Terser in your build.
Checking minified code
After minifying, run your tests, or at least open the page and use its main features. If something breaks, the usual cause is code that relied on a line break instead of a semicolon, which is why the tool keeps those breaks by default.
Keep your original source files, and never edit the minified version by hand.
Questions
Is the output guaranteed to behave identically?
It's designed to, but test it as you would with any minifier.
Does it make code hard to read?
Only because of layout. Names are unchanged.