Code formatter Free
Beautify JSON, CSS, HTML, XML and SQL with consistent indentation and line breaks. Formatting runs in your browser and nothing is uploaded.
About Code formatter
Code formatter turns minified or messy code into something you can read. It re-indents JSON, puts each CSS declaration on its own line, lays out HTML and XML as a nested tree, and breaks SQL into one clause per line with upper-case keywords.
The formatters are small and predictable rather than exhaustive. They change whitespace only: strings, comments and the contents of pre, textarea, script and style elements are left exactly as written, so the formatted code does the same thing as the original.
How to use it
- Choose the language, or open a file and let the extension choose it.
- Paste or type your code, and pick 2 spaces, 4 spaces or tabs.
- Press Format, review the result, then copy it or download it.
Good to know
- This is a beautifier, not Prettier: it does not reorder, wrap long lines or rewrite quotes, and unusual syntax may be laid out simply.
- HTML text is re-flowed, so runs of spaces between words become one space outside pre and textarea. Unclosed tags are indented as written rather than repaired.
- SQL formatting works on common SELECT, INSERT, UPDATE and DELETE statements; procedural code and vendor-specific syntax are formatted only lightly.
- Input is limited to 1,000,000 characters. JSON must be valid; errors show the line and column.
Questions and answers
Will formatting change how my code behaves?
It only changes whitespace and keyword case. In HTML, collapsing spaces in ordinary text can change spacing between inline elements slightly.
Does the JSON formatter round big numbers?
No. Numbers and key order are kept exactly as written, unlike tools that parse and re-print JSON with JavaScript numbers.
Which SQL dialects work?
The formatter knows common keywords shared by PostgreSQL, MySQL, SQLite and SQL Server. Unknown words are left as they are.
