JavaScript Beautifier & Minifier

Format compressed JavaScript with clean indentation or conservatively minify JS by stripping comments and whitespace while preserving strings, regexes, template literals, and ASI boundaries (not an AST identifier mangler).

Private by architecture: All processing is 100% client-side memory. Your data never leaves this browser tab.
JavaScript input
0 lines · 0 charsES / JS
Formatted JavaScript
0 B

About This Tool

Formats compressed or one-line JavaScript into readable, indented code or conservatively minifies JavaScript by removing comments and non-essential whitespace.

Note: This tool uses a deterministic lexical tokenizer rather than a full AST variable mangler or dead-code eliminator. Identifier names remain untouched so stack traces and exported symbols stay intact.

Key Features

  • Tokenizer-aware string & regex safety: Preserves single/double-quoted strings, template literals with nested ${...} expressions, and regular expression literals (/.../gi) without corrupting inner slashes or spaces.
  • Conservative ASI-safe minifier: Avoids merging adjacent tokens (+ +b, return followed by newline) that would trigger Automatic Semicolon Insertion bugs or syntax errors.
  • Configurable indentation: Beautify with 2 spaces, 4 spaces, or hard tabs, with an option to keep or strip comments.
  • Byte size metrics: Displays UTF-8 input bytes, output bytes, and percentage saved in real time.

Frequently Asked Questions

Does this minifier rename variables or tree-shake imports?
No. This tool is a lexical whitespace and comment minifier, not an AST mangler like Terser or esbuild. It strips comments and redundant whitespace while keeping all variable, function, and property names intact.
How does the tokenizer distinguish a regex literal from division?
The lexer tracks the previous significant token. A forward slash following a keyword like return or typeof, or an operator/opening delimiter like (, =, :, or !, is scanned as a regex literal (including character classes [...] and flags); after an identifier, number, or closing bracket, it is treated as division.
Is my JavaScript code uploaded anywhere?
No. Formatting and minification run entirely in your browser tab with zero network requests.