JavaScript Beautifier
Indent JavaScript by braces, with basic string protection.
Enter your details below.
How to use
- Paste your JavaScript into the box.
- Click Beautify JavaScript.
- Read the indented code.
About this tool
This tool protects quoted strings first, then breaks code after braces and semicolons and indents each brace level by two spaces. It is deliberately basic: it does not understand every JavaScript construct, so object literals, arrow functions and complex expressions may indent less neatly than a full formatter would. Use it to make short, straightforward scripts readable, and a dedicated formatter for large codebases.
Frequently asked questions
Does it format complex code perfectly?
No. It is a basic brace-based formatter, so object literals and unusual expressions may not indent as a full formatter would.
Are strings protected?
Yes. Quoted and template strings are set aside before braces and semicolons are split, so braces inside a string do not change the indent.