What minifying does
Minifying makes a JavaScript file smaller so that it downloads and loads faster. This minifier removes comments, indentation, line breaks and every space that the language does not need. The code behaves exactly as before.
// Before
function add(a, b) {
// sum of both
return a + b;
}
// After
function add(a,b){return a+b;}
Safe by design
JavaScript lets a line break end a statement, so deleting every line break can break code that has no semicolons. This tool keeps a line break wherever removing it could change the meaning, for example after return, or before a line that starts a new statement. Strings, regular expressions and template literals are never touched, and a space is kept wherever two words or two plus or minus signs would otherwise join into one.
Options
- Remove comments: deletes line and block comments. A first line that starts with #! is always kept so that command line scripts keep working.
- Keep license comments: keeps block comments that begin with /*! or contain @license or @preserve, which many licenses require you to retain.
The size report
The report shows the original size, the minified size, the percentage saved and the size after gzip, which is what most servers send over the network. Gzip is shown when your browser supports it. Sizes are in bytes of UTF-8 text.
What this minifier does not do
It removes whitespace and comments only. It does not rename variables, remove unused code or rewrite expressions, which is what tools such as Terser and esbuild do. Those tools shrink code further but need a full parser and are best run in your build. Use this page for quick jobs: a snippet, a bookmarklet, an inline script or a file that you want to compare before and after.
To read minified code again, use the JavaScript beautifier. To tidy code you are still writing, use the JavaScript formatter. The formatting guide explains when to use each.