JavaScript Minifier / Formatter

Shrink JavaScript for production or pretty-print it for reading. Strips block and line comments, collapses whitespace, drops trailing semicolons. Live byte count, no upload, all in your browser.

Mode
Options
What this minifier does and does not do

The minifier is a single linear pass over the input — tokenize and re-emit. It is safe on every syntactically valid JavaScript file but conservative on what it rewrites.

It does

  • Strip /* block */ and // line comments.
  • Collapse runs of whitespace into a single space (or not — your call).
  • Remove a trailing semicolon immediately before }.
  • Pretty-print with a configurable indent string.

It does not

  • Mangle identifier names. Manglng breaks stack traces, source maps, and any runtime property lookup (window.foo, globalThis.bar). The cost is too high for a general-purpose tool.
  • Hoist, merge, or fold statements. Without a real AST, every such transform has a counterexample.
  • Touch content inside strings, template literals, regex literals, or comments — including things that look like comments inside a string.