JavaScript Minifier
Strip comments and unneeded whitespace from JavaScript to cut file size, while keeping strings, template literals, and regex expressions byte-identical.
How to use
- Paste JavaScript into the input.
- Turn on keeping comments only for a licence header.
- Copy the single-line output.
A JavaScript minifier removes comments and whitespace that sits between tokens where it changes nothing. Strings, template literals, and regex literals are tokenised first and copied through untouched.
Paste or type something above.
Questions about javascript minifier
- Is the output safe to run?
- The minifier only removes whitespace and comments, so behaviour is unchanged. It is not a bundler and will not rename or tree-shake.
- What about ASI and semicolons?
- A space is preserved wherever two identifier characters would otherwise merge, and statement-ending semicolons are kept.
- Does it handle modern syntax?
- Yes, including template literals, optional chaining, nullish coalescing, and class fields, since only whitespace is touched.
Related tools
- JavaScript Formatter Re-indent JavaScript with consistent braces and line breaks, using a tokenizer that keeps...
- CSS Minifier Remove comments and redundant whitespace from CSS to shrink the file, keeping strings and...
- HTML Minifier Strip comments and redundant whitespace from HTML to cut page weight, keeping one meaningf...