Common JSON errors and how to fix them
Most invalid JSON comes from a handful of mistakes: a trailing comma, single quotes instead of double quotes, unquoted keys, comments, or a missing bracket. JSON is strict, so each of these fails to parse even though many programming languages allow them.
Try it: JSON Repair & Auto-fixFix quotes, commas, comments and missing brackets in one click, with a list of every fix.Trailing comma
A comma after the last item is allowed in JavaScript but not in JSON.
{ "a": 1, "b": 2, } // invalid
{ "a": 1, "b": 2 } // validTypical message: Unexpected token } in JSON at position 17. Remove the comma before the closing bracket.
Single quotes
JSON strings and keys must use double quotes. Replace 'name' with "name".
Unquoted keys
In JSON every key is a double-quoted string. {name: "Asha"} must be {"name": "Asha"}.
Comments
JSON has no comment syntax. Lines starting with // or blocks in /* */ must be removed. Configuration formats such as JSONC allow them, but standard parsers do not.
Python and JavaScript values
True, False and None are Python. JSON uses true, false and null. JavaScript's undefined and NaN are not valid JSON either.
Missing commas and brackets
Two values next to each other need a comma between them. Every { needs a }, and every [ needs a ]. Copying only part of a response is the usual cause of a missing closing bracket.
Control characters inside strings
A raw line break inside a string is not allowed. Write it as \n. The same applies to tabs, which become \t.
Fix them automatically
The JSON Repair tool fixes all of the above in one step and lists every change it made, so you can check the result.
Frequently asked questions
Why does JSON.parse say "Unexpected token"?
The parser found a character that is not allowed at that position, such as a single quote, a comment, or a trailing comma. The position in the message points to it.
Is a trailing comma ever valid JSON?
No. The JSON specification does not allow trailing commas, although JSON5 and JavaScript do.
Published 2026-10-23. Last updated 23 October 2026.