Data & development
How to find and fix JSON errors, then format JSON
The JSON mistakes that break parsers most often — quotes, commas, comments, True/False — how to locate them, and how to format, minify and inspect JSON.
Published:
Example: a config file that will not load
This looks reasonable, but every JSON parser rejects it:
{
'name': "Tokyo Tower",
"height_m": 333,
"open": True,
"tags": ["landmark", "observation",],
// opened in 1958
}
Finding the errors one by one
- Open the JSON formatter and paste the text into JSON input.
- Press Validate only (or Format). The tool stops at the first error, shows its line and column, and highlights the spot under Where the error is.
- Fix that one problem and validate again. Repeat until you see Valid JSON.
For the example, the errors appear in this order:
| Line | Message (summary) | Fix |
|---|---|---|
| 2 | Strings and keys need double quotes, not single quotes | 'name' → "name" |
| 4 | True is not a JSON value; use lowercase |
True → true |
| 5 | Trailing comma before the closing bracket | remove the , after "observation" |
| 6 | JSON does not allow comments | delete the comment line |
| 5 | Trailing comma (once the comment is gone, "tags" is the last item) |
remove the , after ] |
The corrected JSON:
{
"name": "Tokyo Tower",
"height_m": 333,
"open": true,
"tags": ["landmark", "observation"]
}
The most common causes
- Single quotes — JSON only accepts
"double quotes"for strings and keys. - Trailing commas — allowed in JavaScript, not in JSON.
- Comments —
//and/* */are not part of JSON. Move notes into a field such as"note"if you need them. - Python or JavaScript values —
True,False,None,undefinedandNaNare not JSON. Usetrue,falseandnull. - Unescaped characters inside strings — a raw line break or tab inside a string must be written as
\nor\t. - The text was cut off — “The JSON ends too early” usually means a missing
}or], often from copying only part of a response.
Formatting, minifying and the tree view
- Format adds line breaks and indentation (choose 2 or 4 spaces or tabs under Indent) so you can read the structure.
- Minify removes all unnecessary spaces to make the smallest one-line version, for example before putting JSON in a URL parameter or an environment variable.
- Tree view shows objects and arrays as collapsible sections with Expand all / Collapse all, which helps with deeply nested API responses.
Things that are valid but still surprising
- Large numbers.
{"id": 12345678901234567890}is valid JSON, but JavaScript’sJSON.parseturns it into12345678901234567000. The formatter keeps numbers exactly as written, so IDs are not silently changed. If your own code needs exact large IDs, send them as strings. - Duplicate keys.
{"a": 1, "a": 2}is accepted by most parsers, which keep only the last value. The formatter warns you and lists where the duplicates are.
Related tasks
- Turn an array of objects into a spreadsheet with JSON ⇄ CSV.
- Compare two versions of a JSON file line by line with text compare — format both first so the differences line up.