What you get
Paste JSON from an API response, a log, or a config file, and it comes back indented and easy to read. This one-liner:
{"user":{"id":42,"name":"Sam","tags":["admin","beta"]},"active":true}
becomes:
{
"user": {
"id": 42,
"name": "Sam",
"tags": [
"admin",
"beta"
]
},
"active": true
}
Switch to Minify to get the one-liner back. The result shows the line count and the size before and after. For other code, pick the language from the menu: the same box formats HTML, CSS, JavaScript, XML, and SQL.
When the JSON is broken
The checker reads JSON the strict way the standard describes and stops at the first problem. It shows the line and column, the line itself with a marker under the spot, and what’s wrong in words, not codes:
| Mistake | Example | Fix |
|---|---|---|
| Missing comma | "a": 1 "b": 2 |
Add a comma between items |
| Comma after the last item | [1, 2, ] |
Remove the last comma |
| Single quotes | {'name': 'Sam'} |
Use double quotes |
| Key without quotes | {name: "Sam"} |
Put the key in double quotes |
| Python or JavaScript words | True, None, undefined |
Use true, false, or null |
| A comment | // note |
Remove it; JSON has no comments |
It also warns when the same key appears twice in one object. That’s allowed, but most programs keep only the last value, so it’s usually a mistake.
Other languages
HTML formatter
Each element goes on its own line, indented by depth, and CSS and JavaScript inside <style> and <script> are formatted too. Line breaks are only added where browsers ignore them, so inline tags like <b> and <a> stay with their words and the page looks the same. Minify removes comments and extra spaces but keeps <pre> and <textarea> text exactly.
CSS formatter
One property per line, a space after each colon, and media queries and nested rules indented by level. Minify removes comments and spaces and shortens what it safely can, like #ffffff to #fff. A missing } is reported with the line where the block opened.
JavaScript formatter
Unminifies scripts into readable code with consistent spacing, quotes, and semicolons. Modern syntax and JSX work; TypeScript type annotations don’t yet. Minify also shortens local variable names, so test minified code before you ship it.
XML formatter
Pretty prints XML, SVG, RSS, and sitemaps, and checks that every tag is closed in the right order. Errors name the tag, like “Expected </b> but found </a>”. It checks that XML is well formed, not that it matches a schema.
SQL formatter
Turns a one-line query into clauses on their own lines with keywords in capitals, and indents subqueries inside their brackets. Choose your SQL type (Standard, MySQL, PostgreSQL, SQL Server, or SQLite) so its keywords and quotes are read correctly. Text in quotes is never changed.
How it works
- JSON is read character by character against the JSON standard (RFC 8259), with my own checker, so numbers and text are copied exactly as written.
- HTML, CSS, JavaScript, and XML are formatted with Prettier, the open-source formatter many code editors use. SQL uses the open-source sql-formatter library.
- Minifying uses csso for CSS and terser for JavaScript; HTML, XML, and SQL use my own careful minifiers that never touch quoted values or text inside tags.
- Speed: each language’s formatter loads only the first time you use it, and big files are processed in the background so the page keeps working.
Limits
Only standard JSON is accepted: JSON5 and JSON with comments show an error at the first comment or unquoted key. Template code mixed into HTML, CSS, or SQL (PHP, Jinja, {{ }}) can confuse the formatter. Very large files, tens of megabytes, depend on your device’s memory.