JavaScript Beautifier
Reformats minified or messy JavaScript into consistently indented code.
Loading the tool…
How to use this tool
- Paste the minified or badly formatted JavaScript.
- Set the indent size, or switch to tabs.
- Select Format.
- Run the result through again if you want to confirm the formatting is stable — it produces the same output.
What javascript beautifier does
Reading a minified bundle, or a snippet pasted out of a log with every line run together, is close to impossible until it is laid out. This page re-indents it: braces open a level, statements go on their own lines, object properties get a line each, and spacing follows the usual conventions — a space after a keyword, none between a function name and its argument list.
Only braces change the indent. Parentheses and square brackets are tracked, but only so a semicolon inside for(;;) is not mistaken for the end of a statement and a comma between array elements does not become a line break — breaking on those is what turns a short call into six lines of nothing. Ternaries keep their spacing, object keys do not, and the two are told apart properly rather than guessed at. Comments are kept by default and can be dropped. Running the result through again produces the same output, so the formatting is stable.