JavaScript Formatter
Make minified or inconsistently indented JavaScript readable. Statements are placed on their own lines, blocks are indented, and long chains are broken up — without renaming anything, reordering anything, or changing what the code does. Handy for reading a bundled file or normalising a snippet pasted from elsewhere.
Developer Tools
Private by default
This tool runs entirely in your browser. Your data is never uploaded to a server.
How it works
What changes and what cannot
Statements are separated onto their own lines, blocks gain an indent level, and operators keep consistent spacing. Identifiers, string contents, and the order of operations are never touched, so the program that comes out is the program that went in.
- Template literal contents are preserved exactly — their whitespace is part of the resulting string.
- Comments stay attached to the line they were on rather than being collected elsewhere.
- Regular expression literals are recognised as such, so a `/` inside one is not mistaken for division.
- This is a formatter, not a transpiler or minifier: nothing is downlevelled, tree-shaken, or renamed.
For reference
What a minifier removed, and whether it comes back
| Removed by minification | Recoverable |
|---|---|
| Indentation and line breaks | Yes — that is this tool |
| Spaces around operators | Yes |
| Original variable names | No — only a source map can |
| Comments | No — deleted from the file |
| Dead code that was eliminated | No |
| Original file boundaries | No — only a source map can |
If a .map file sits next to the bundle, load it in your browser's devtools instead: it restores names, comments, and the original files.
How to use
4 clear steps.
Paste the JavaScript, minified or not.
Choose the indentation and optional wrap length.
Read the expanded code.
Copy the formatted result.
Good to know
Frequently asked questions
- Will formatting break my code?
- It should not: only whitespace is changed and statements already carry their own semicolons after formatting. Code that relies on automatic semicolon insertion in unusual ways is the one place to double-check, and it is worth having tests before reformatting anything you cannot re-verify.
- Can it recover minified variable names?
- No. Minifiers throw the original names away — `a`, `b`, and `t` are all that is left in the file. Formatting restores the shape of the code, not its vocabulary. A source map is the only thing that can recover the original.
- Does it work with JSON or TypeScript?
- JSON is valid JavaScript syntax, so it formats cleanly — though the dedicated JSON Formatter also validates it. TypeScript mostly works, but type annotations are not part of the JavaScript grammar, so unusual generics can be laid out oddly.