Code Beautifier
A multi-language code beautifier - choose JavaScript, CSS, HTML, JSON or C-style code (PHP, Java, C#) and get consistently indented output.
Choose the language and indentation, paste your code, and get consistently formatted output - JavaScript, CSS and HTML use the js-beautify library, JSON a real parser.
JavaScript, CSS and HTML are formatted with the js-beautify library and JSON with a real JSON parser. PHP, Java and C-family code is re-indented by brace nesting - it does not check syntax. For Python and SQL, use the Python Formatter and SQL Formatter.
More Programming Language Tools
View all 23For a page dedicated to just one language with more detailed guidance, see that language's own formatter in this category.
What Does This Tool Do?
It re-formats code so it is readable again: consistent indentation, one statement per line and tidy spacing. Choose the language first - JavaScript (including TypeScript syntax), CSS and SCSS, and HTML are formatted with the widely used js-beautify library; JSON is parsed and pretty-printed; PHP, Java, C, C++ and C# are re-indented by brace nesting.
Why Use This Tool?
Code copied from a minified file, a chat message, a ticket or an AI assistant often loses its layout. One page for several languages is convenient when you switch between front-end and back-end code in the same session.
How to Use It
- Choose the language and the indentation you want (2 spaces, 4 spaces or tabs).
- Paste your code.
- Click Beautify and copy the result.
Limitations
Formatting never fixes syntax errors, and invalid JSON is reported instead of formatted. The brace-based mode for PHP and C-family languages changes indentation and line breaks only - it does not rewrite spacing inside a line. Python and SQL have their own dedicated formatters.
Example
Minified JavaScript such as:
function total(items){let sum=0;for(const i of items){sum+=i.price*i.qty}return sum}
comes back as:
function total(items) {
let sum = 0;
for (const i of items) {
sum += i.price * i.qty
}
return sum
}
When a Beautifier Helps
- Reading a minified third-party script to find out what it does.
- Reviewing code pasted into a ticket, chat or email, where indentation was lost.
- Tidying a snippet before adding it to documentation or a blog post.
- Making SQL from logs or ORMs readable while debugging slow queries.
Beautifier vs Your Project's Formatter
For code in a repository, use the formatter your team has configured - Prettier, PHP-CS-Fixer or Pint, Black or Ruff - so everyone's editor produces identical output and diffs stay clean. A browser beautifier is best for quick, one-off reading and sharing.
Each language also has its own page: JavaScript, PHP, Python, JSON and SQL. To go the other way, use the Code Minifier.
Frequently Asked Questions
Explore More Tools
Keep going with related categories and our most used tools.