How to use JavaScript Minifier
- Paste the JavaScript.
- Decide whether license comments (or all comments) should be kept.
- Copy or download the minified script.
JavaScript Minifier features
- Strips comments and all unnecessary whitespace
- Preserves line breaks that matter for automatic semicolon insertion
- Keeps /*! license */ and @license/@preserve comments (optional)
- Strings, template literals and regex literals are never modified
- No renaming or code transformation — output stays debuggable
- Displays original size, minified size and savings
JavaScript Minifier example
Minify a helper
Input:
// add numbers
function add(a, b) {
return a + b;
}Output:
function add(a,b){return a+b;}Frequently asked questions about JavaScript Minifier
How is this different from Terser or esbuild?
This tool removes whitespace and comments only; it does not rename variables, inline constants or drop dead code. That keeps the output readable in stack traces and makes it safe for quick copy-paste use.
Is the output safe with automatic semicolon insertion?
Yes. A line break is kept wherever removing it could change the meaning (for example before a line starting with ( or [ or a template literal), so ASI-dependent code keeps working.
Can I keep the license header?
Comments starting with /*! or containing @license / @preserve are kept by default. Untick the option to remove them too.
What savings should I expect?
Typically 20–40% on hand-written code, mostly from indentation and comments. The stats panel shows the exact bytes saved.
Technical notes
A safe minifier only removes what cannot change semantics. Whitespace between two identifier characters is reduced to one space, "+ +" and "- -" sequences keep their space, and a newline is kept between an expression end and an expression start (for example before "(" or "[") so ASI rules still apply.