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).
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.