About the JavaScript Formatter
This tool is a whitespace-based re-indenter for JavaScript: it tracks brace depth to indent code and inserts line breaks after braces and semicolons, while carefully preserving the contents of strings, template literals and both comment styles so it never corrupts code. It's meant for quickly tidying up minified or inconsistently indented snippets, not for full code formatting.
How to use it
- 01Paste your JavaScript code into the input panel.
- 02Choose an indent width.
- 03Review the re-indented output.
- 04Copy or download the result as a .js file.
Features
- Brace-depth based indentation with line breaks after { } and ;
- String, template literal and comment contents are never modified
- Handles escaped quotes inside string literals correctly
- Copy and download as a .js file
Practical examples
Expanding minified code
Paste a single-line minified script to get a readable, indented version for quick debugging or inspection.
Limitations
- This is a whitespace re-indenter, not a full AST-based formatter like Prettier — it does not reformat wrapping of long lines, add or remove semicolons, or normalize quote styles.
- Highly unusual syntax such as regex literals containing brace-like characters may occasionally confuse the brace counter.
Privacy
All formatting happens locally in your browser; your source code is never sent anywhere.
Read the full privacy policy for how the site as a whole handles data.
Frequently asked questions
Is this the same as Prettier?
No, it's a much simpler brace-based re-indenter and does not implement a full JavaScript parser or Prettier's formatting rules.
Will it break my template literals?
No, template literal contents between backticks are copied through untouched, including embedded ${} expressions.
Does it minify code?
No, this tool only re-indents for readability; use the JSON minifier or a dedicated JS minifier for size reduction.