JavaScript Minifier
Strip comments and normalise whitespace from JavaScript in ASI-safe mode — strings and template literals are copied verbatim, newlines preserved.
Reviewed 17 November 2026 · Free · No account needed
How to use
- Paste your JavaScript.
- Read the minified output and the saved percentage.
- Copy the result for quick bundle trimming.
Example
Input: // init const url = "a b";
Output: const url = "a b"; (string spaces preserved)
How it works
Comments and unnecessary whitespace are removed from the JavaScript and statements are compacted. The code's behaviour is unchanged — only its size is reduced.
One pass removes // and /* */ comments and collapses whitespace runs, keeping at most one newline per run so automatic semicolon insertion (ASI) never changes meaning. String literals and template literals are copied verbatim, including their internal spaces and indentation.
// init const url = "a b"; becomes const url = "a b"; — the comment is gone, the two spaces inside the string survive.
Edge cases to know
- No renaming, dead-code elimination or mangling — use a build tool for that.
- A comment between two words is replaced by one space, so a/**/b never becomes ab.
- Regex literals are treated as unknown tokens: their contents survive untouched, but this is not a full parser.
- Newlines are kept deliberately so ASI behaviour cannot change.
Limits & compatibility
- No renaming, dead-code elimination or mangling — use a build tool for that.
- Regex literals are treated as unknown tokens: patterns survive, but this is not a parser.
- Newlines are kept so automatic semicolon insertion never changes meaning.
Privacy
Your code never leaves the browser. There is no server call, no storage and no logging of content.
Related tools
Questions about JavaScript Minifier
Is it safe for code that relies on automatic semicolon insertion?
Yes — newlines are preserved wherever one existed in the source, precisely so automatic semicolon insertion cannot change meaning. Other whitespace is collapsed, comments are stripped, and a comment between two words leaves a space behind so a/**/b never becomes ab. Strings and template literals are copied through untouched.
Does it rename variables or remove dead code?
No — there is no renaming, mangling or dead-code elimination; those need a real build tool with a parser and scope analysis. This minifier strips comments and normalises whitespace only, which makes it useful for quick bundle trimming or small scripts rather than replacing your production build pipeline.
How are strings, template literals and regexes handled?
Strings and template literals are copied verbatim, including escapes and internal indentation — trimming a template literal would change what the program prints. Regex literals are treated as unknown tokens: the pattern survives, but the tool is not a JavaScript parser, so pathological inputs are handled conservatively rather than cleverly.