About the JSON Formatter
The JSON Formatter re-indents JSON so it is easy to read. Paste a compact API response or config file, choose 2 spaces, 4 spaces or tabs, and copy the formatted result. If the input is not valid JSON, the parserโs error message tells you what went wrong.
How to use the JSON Formatter
- Paste your JSON.
- Choose the indentation.
- Copy the formatted output, or read the error message if parsing fails.
Example
Before and after
{"id":7,"tags":["a","b"]} becomes:
{
"id": 7,
"tags": [
"a",
"b"
]
}
JSON syntax rules
- Keys must be strings in double quotes:
{"name": "Ali"}. - Strings use double quotes, never single quotes.
- Values can be a string, number,
true,false,null, an object or an array. - Items are separated by commas, with no comma after the last item.
- Comments are not allowed.
Common JSON errors and fixes
| Error | Invalid | Valid |
|---|---|---|
| Trailing comma | [1, 2, 3,] | [1, 2, 3] |
| Single quotes | {'a': 1} | {"a": 1} |
| Unquoted key | {a: 1} | {"a": 1} |
| Comment | {"a": 1 // id} | {"a": 1} |
| NaN or undefined | {"a": NaN} | {"a": null} |
To check syntax only, use the JSON Validator; to compare two documents, the JSON Diff; to turn JSON into a spreadsheet, JSON to CSV.