JSON Beautifier
Format and validate JSON data for better readability
Tip: Paste your minified or compact JSON and click Beautify to format it with proper indentation. The tool will also validate your JSON syntax.
Runs in your browserInput JSON Data
Format JSON so you can read it
Paste JSON, open a .json file or drop it on the input window, and it is formatted as you type: one key per line, nested objects indented, with 2 spaces, 4 spaces or tabs. JSON beautifier and JSON formatter are two names for the same job, and this page does both.
Formatting starts by reading the JSON with the browser's strict parser, so it validates the syntax on the way. If something is wrong, the result window says where (line and column) and the cursor jumps to that spot in your input.
JSON formatter example
A one-line API response, formatted with the default 2-space indent:
{"order":{"id":"A-1042","paid":true,"total":59.9,"items":[{"sku":"MUG-01","qty":2},{"sku":"TEE-L","qty":1}],"note":null}}
{
"order": {
"id": "A-1042",
"paid": true,
"total": 59.9,
"items": [
{
"sku": "MUG-01",
"qty": 2
},
{
"sku": "TEE-L",
"qty": 1
}
],
"note": null
}
}
Why your JSON is invalid
JSON is stricter than JavaScript. These five cause most of the errors the validator reports:
-
Error
{"a": 1,}FixNo comma is allowed after the last item of an object or array. Delete it.
-
Error
{'a': 'b'}FixStrings and keys need double quotes. Single quotes are JavaScript, not JSON.
-
Error
{a: 1}FixEvery key is a string in double quotes:
{"a": 1}. -
Error
// noteFixJSON has no comments. Remove them, or keep the file as JSONC or JSON5 for the tool that reads it.
-
Error
NaN,undefinedFixNot JSON values. Use
null, a number or a string instead.
Syntax is only the first check. To test that valid JSON also has the right fields and types, write a schema: JSON Schema validation explains how.
Indent, sort keys and what stays the same
Options
- Indent: 2 spaces (the default most style guides use), 4 spaces or one tab per level
- Sort keys: every object's keys in alphabetical order, at every level, so two files can be compared line by line
- Arrays keep their order either way
Worth knowing
- Whole numbers above 9007199254740991 lose precision, as in any JavaScript parser: keep long IDs as strings
1.0is written as1, and escapes like\u00e9as the character itself- If a key appears twice in one object, the last value wins
Need it on one line again?
The JSON minifier removes every space and line break and shows how many bytes it saved.
JSON beautifier questions
None in practice: both add line breaks and indentation so JSON is readable, and both are also called pretty printing. The opposite is minifying.
Yes, for syntax. JSON that can't be parsed is not formatted; you get the error with its line and column instead.
Click Open file or drop the file on the input window. It is read in your browser; Download saves the formatted copy as a .json file.
Not here, but the converters can: JSON to CSV, JSON to YAML and JSON to XML.
No. Formatting runs in your browser.