A JavaScript beautifier turns minified one-liners and inconsistently indented code into clean, readable JavaScript. When you copy a snippet from a bundle, a minified library, or a colleague’s compressed paste, reading it is painful. This formatter re-indents the code in your browser using the indentation style you choose, with no upload and no install.
How it works
The formatter first tokenizes the source. It walks the code character by character and recognises strings, template literals, regular-expression literals, and comments as whole tokens, copying them verbatim. This matters because a {, }, or ; inside a string must not affect the layout. The tricky / character is classified as a regex or a division operator based on the preceding significant token, the same heuristic a real parser uses.
With the tokens identified, the beautifier re-emits the code: it increases the indent level after every {, decreases it before every }, and starts a new line after each } and ;. Closing braces that are immediately followed by ), ,, ;, or . stay on the same line so method chains and callback arguments read naturally. You can pick 2-space, 4-space, or tab indentation.
Notes and limitations
This tool focuses on indentation and statement layout. It does not wrap long lines to a fixed print width or rewrite quote styles, which is where full formatters like Prettier go further. For most debugging and code-reading tasks, fast, deterministic re-indentation is exactly what you need. Everything runs locally, so it works offline and keeps your code private.