JavaScript Beautifier
Professional-grade JavaScript formatter and de-obfuscator. Transform minified code into clean, readable syntax with customizable indentation, brace styles, and syntax highlighting.
About
In the ecosystem of modern web development, code readability is not merely aesthetic - it is a functional necessity. This JavaScript Beautifier engine addresses the critical need to transform minified, obfuscated, or poorly formatted scripts into strict, standardized syntax trees. Minification (removing whitespace/comments) is essential for production payload optimization (reducing kiloBytes), but it renders code illegible for human debugging.
This tool utilizes a custom lexical tokenizer to parse the Abstract Syntax Tree (AST) structure of your code. Unlike simple regex replacers, it respects context - preserving strings, differentiating between division operators (/) and Regular Expressions, and maintaining valid logic flows. Whether you are auditing third-party libraries, debugging legacy systems, or enforcing team style guides (e.g., Airbnb, StandardJS), this engine provides granular control over indentation depth, brace placement, and operator spacing.
Formulas
The core logic follows a recursive descent strategy to calculate indentation depth D at any given line L based on the token stack:
Operator spacing is applied via token type analysis, ensuring x=y becomes x = y while preserving unary operators like ++i.
Reference Data
| Style Guide | Indentation | Semicolons | Quotes | Trailing Comma | Brace Style |
|---|---|---|---|---|---|
| Airbnb | 2 Spaces | Required | Single | ES5 (Multi-line) | Collapse (One True Brace) |
| 2 Spaces | Required | Single | None | Collapse | |
| StandardJS | 2 Spaces | Forbidden | Single | None | Collapse |
| jQuery Core | Tabs | Required | Double | None | Collapse |
| Idiomatic.js | Tabs / 4 Spaces | Required | Single | None | Expand / Collapse |
| CommonJS | Tabs | Required | Single | None | Collapse |
| Crockford | 4 Spaces | Required | Single | None | End of Line |