About this tool
The JavaScript Beautifier reformats minified, one-line, or inconsistently indented JavaScript and JSON into clean, readable source with uniform indentation and spacing. It is handy for reading a bundled library, tidying a copied snippet, or inspecting a JSON blob. Everything happens in your browser — the code is only reformatted as text, never executed, so there is no eval, no new Function, and nothing is uploaded.
The formatter is a hand-written tokenizer, not a regex hack: it scans the source into tokens while correctly skipping over the interiors of strings, template literals, regular expressions, and line/block comments, so quotes and slashes inside those are never mistaken for structure. A classic lookbehind heuristic distinguishes a division operator from a regular-expression literal. The token stream is then re-emitted with newlines after '{', '[' and ';', dedented lines before '}' and ']', one item per line inside object and array literals, and a single space around operators and after keywords.
Choose an indent of 2 spaces, 4 spaces, or a tab, and a brace style: collapse keeps the opening brace on the same line (K&R / 1TBS), while expand moves it onto its own line (Allman). Because the tool preserves string and regex contents byte-for-byte, the reformatted code is semantically identical to the input. Copy the result straight into your editor.