Toolverge

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.

108 → 74 bytes (31% smaller)

function add(a,b){return a+b;}const pattern=/^\d+$/;console.log(add(2,3));

How it works

  1. Paste JavaScript in the box.
  2. Read the minified output and the byte-size reduction.
  3. 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.