JavaScript Minifier
A JavaScript minifier strips line and block comments and collapses non-essential whitespace, carefully distinguishing a `/` that starts a regular expression from one that means division so regex literals are never corrupted, and never touching content inside strings or template literals. A forward slash in JavaScript can start either a division operation or a regular-expression literal depending on what came before it, and treating one as the other is a classic way a naive minifier corrupts working code — correctly telling them apart is what lets comments and whitespace be removed safely without touching a regex pattern.
How it works
- Paste JavaScript in the box.
- Read the minified output and the byte-size reduction.
- Copy the result with the Copy result button.
Formula Strip comments; collapse whitespace; preserve strings, template literals, and regex literals verbatim
Frequently asked questions
Does this rename variables or shorten function names?
No — this is a comment-and-whitespace minifier, not a full optimizer like Terser. It never renames anything, so there is no risk of breaking references.
Will this break a regular expression like /a\/b/?
No — regex literals (including escaped slashes and character classes) are detected and copied through untouched, distinguishing them from division.
Does this handle template literals?
Yes for typical use — backtick strings are preserved verbatim. Deeply nested ${...} expressions containing further backticks are a known edge case this tool does not fully parse.
Could minifying ever change what my code does?
It is designed not to — whitespace is only removed where JavaScript treats it as insignificant, and a specific safeguard keeps a space where removing it would merge characters into a different operator (e.g. turning "a - -b" into "a--b").
Is my code uploaded anywhere?
No. Minification runs entirely in your browser.