Skip to content
← Back

JS Minifier / Formatter - Online JavaScript Compression

Code
Runs locally · Not uploaded

Online JavaScript minify and format: strip comments, optionally drop console/debugger, compact punctuation; protects strings and regex; shows char/UTF-8 size delta. Runs locally.

Was this result helpful?

For local tools, open DevTools → Network and search your input — it should not appear in requests.

Usage Guide

JS size drives load time: stripping comments and extra whitespace often cuts hand-written source by roughly a third. This tool minifies locally in the browser (nothing uploaded) and shows character vs UTF-8 byte savings — identifier names stay intact so runtime name lookups are not broken.

1. Minify a script

  1. Paste JavaScript (ES5 and common ES6+ both work).
  2. Toggle options: remove comments, drop console.*, drop debugger, compact punctuation spacing.
  3. Minify and read the char/byte savings; use Format (Prettier) when you need readability back.
  4. Smoke-test before shipping — especially after dropping console, confirm no retry logic depends on logs.

2. What this tool does — and does not

  • Does: strip comments (keeps /*! and @license), collapse whitespace, optional console/debugger removal, protect strings and regex literals.
  • Does not: mangle names, dead-code eliminate, or constant-fold — that belongs to Terser/esbuild in a build pipeline.
  • Unbalanced brackets surface a line/column warning while minify still runs — treat it as a clue, not a fix.

3. Two checks before minifying

  • Keep the source copy: minification is irreversible; the output is a build artifact.
  • Legacy ASI-heavy code can change meaning when lines collapse — run unit tests after minifying.

4. The right way in production

Bundlers minify during build. Use this tool for static pages without a pipeline, one-off script shrinks, or measuring how much drop-console saves. Hand-minifying every release is the signal to automate.

5. Reading the size numbers

The panel reports both characters and UTF-8 bytes. With CJK comments or non-ASCII strings, byte savings often exceed character savings — CDNs bill bytes. Brotli/Gzip stack on top of source minify; they do not replace it.

FAQ

Lexical-level compression: it strips comments and redundant whitespace, tightens punctuation spacing, and can optionally drop console calls and debugger statements. String, template, and regex literals are stashed before processing, so content like "https://..." never gets eaten by comment stripping.

No. There is no identifier renaming and no full tree-shaking or compatibility transpiling here — those belong to a bundler and its CI pipeline. For project-scale builds, treat your bundler config as the source of truth; this page is for ad-hoc snippets.

It only touches comments, whitespace, and optional debug statements — it never rewrites your syntax. If the source itself has a syntax error (unmatched brackets, for example), minification fails and points to the location, so fix the syntax first.

Blocks starting with /*! and blocks containing an @license marker are preserved automatically; ordinary comments go away by default. Generating sourcemaps is out of scope — use your build tooling for those.

Yes, inputs over 2MB are rejected with a message telling you to split the file. Confirm your option combo and output on a small sample first, then work through long files in segments.

No. Everything runs inside the browser with no third-party minifying service involved, which makes it comfortable for unreleased code.

Related Tools

Related Articles