JS Minifier

Online JS Minifier

This tool strips comments and unnecessary whitespace from JavaScript to reduce file size, while carefully tracking strings, template literals, and regular expressions so a // or /* */-looking sequence inside one of those is never mistaken for a real comment and stripped.

Features:

  • Comment removal: Strips both // line comments and /* */ block comments.
  • Whitespace collapsing: Removes extra blank lines and leading/trailing whitespace.
  • String-safe: Never touches the contents of strings, template literals, or regex literals.
  • Client-side only: Your source code never leaves your browser.

1. What This Does and Doesn't Do

This is comment-and-whitespace minification, not full AST-based minification. It won't rename variables, shorten function names, or restructure control flow the way build-time tools like Terser or esbuild do — those need a real JavaScript parser and carry more risk of subtly changing behavior. This tool is the safe subset: purely cosmetic size reduction with no semantic changes.

2. When to Use This vs. a Build-Time Minifier

Reach for this when you need a quick one-off size check or a lightweight script with no build pipeline behind it. For a production bundle, use a real bundler-integrated minifier — it will do everything this does plus much more, and it runs as part of your build rather than manually.

Does this rename variables like a "real" minifier? No. This strips comments and unnecessary whitespace only. Renaming variables and restructuring code needs a full parser and carries more risk of subtly changing behavior.
Will this break my code? It is designed not to: strings, template literals, and regular expressions are tracked and left untouched. Still, always test minified output before shipping it.
How much size reduction should I expect? Typically 15-30% for well-commented code, less for code that is already dense. For serious size reduction, pair this with a real build-time minifier like Terser or esbuild.

Need the reverse? Format minified code back to readable with the JS Formatter.

100% client-side — your source code is never uploaded.

Related Tools