JavaScript Minifier & Beautifier

Minify for compact size or beautify for readability — fully client-side for privacy.

Input & Options

Input: 0 B Output: 0 B Saving: —

Output

About this tool

This JavaScript Minifier & Beautifier runs entirely in your browser—no uploads, no tracking, and no external APIs. The minifier uses a conservative tokenizer to safely remove comments and extra whitespace while preserving strings, regular-expression literals, and template literals (including nested ${...}). The beautifier applies indentation based on braces and statement boundaries for a readable result.

Options in brief

  • Remove comments – Strips // and /* ... */ comments.
  • Keep license – Preserves /*! ... */ banner comments (common for licenses).
  • Collapse whitespace – Removes unnecessary spaces/newlines (keeps what’s required for correctness).
  • Safe semicolons – Inserts semicolons in edge cases (e.g., between ) and [, or after return before a regex literal).

Keyboard shortcut: Ctrl/Cmd + Enter runs Minify. Your last input persists locally so you can pick up where you left off.

FAQ

Does any code I paste get uploaded?

No. This tool runs entirely in your browser. Nothing is sent to any server.

Is this as aggressive as production minifiers like Terser?

It’s intentionally conservative for safety and privacy. It removes comments/whitespace and preserves behavior, but does not perform advanced AST transforms or mangling.

Will it keep license headers?

Yes — enable “Keep /*! ... */ license banners” to preserve license comments.

5 Fun Facts about Minifying JS

Regex vs division

Minifiers must tell /foo/ (a RegExp) from a/b (division). Heuristics look at the token before the slash to decide.

Slash detective

ASI isn’t magic

Automatic Semicolon Insertion works, but edge cases (return then newline then /regex/) can bite. Safe minifiers add semicolons in risky spots.

Return traps

Banner comments stay

Comments starting with /*! … */ are often licenses. Minifiers keep them when you enable the option, dropping the rest for size.

License friendly

Whitespace saves bytes twice

Less whitespace means smaller bundles before gzip/brotli, which makes compression ratios even better.

Compounding gains

Beautify to spot bugs

Pretty-printing can expose dangling braces or mismatched indentation that hide in minified blobs—great before code reviews.

Readable diffs

Explore more tools