Fix Invalid JSON: The 5 Errors That Break Every Payload
JSON is strict on purpose, and its parser fails loudly at the first rule it sees broken. The good news: in practice, almost every invalid payload is one of the same five mistakes. Learn these and you can fix most JSON errors on sight.
1. The trailing comma
JSON forbids a comma after the last item. This is the single most common error, because JavaScript allows it and JSON does not.
Broken: {"name": "Alice", "age": 30,}
Fixed: {"name": "Alice", "age": 30}
Delete the final comma and the payload parses.
2. Single quotes
Every string and every key in JSON must use double quotes. Single quotes are valid in JavaScript and Python, which is exactly why they sneak into JSON so often.
Broken: {'name': 'Alice'}
Fixed: {"name": "Alice"}
3. Unquoted keys
Object keys must be quoted strings, always. Writing keys bare, JavaScript style, fails immediately.
Broken: {name: "Alice"}
Fixed: {"name": "Alice"}
4. Comments
JSON has no comment syntax at all. Both // line comments and /* block comments */ make a file invalid the moment they appear. If a config format you use does allow comments, it is a JSON superset like JSONC, not JSON itself. Before pasting into anything that expects real JSON, strip the comments.
5. Missing or mismatched brackets
Every { needs its } and every [ needs its ]. In a payload nested four levels deep, a single missing brace produces an error message pointing at the end of the file, far from the actual mistake. Indentation is the antidote: a properly formatted payload makes the structure visible, and the missing bracket jumps out.
Let the parser find it for you
Hunting these by eye in a 4,000 character single line API response is miserable. Paste the payload into the free JSON Formatter instead: it validates with the same JSON.parse engine your application uses, shows the exact parser error when something is wrong, and pretty prints the structure so nesting problems become visible. If it parses there, it will parse in your code.
The bottom line
Trailing commas, single quotes, bare keys, comments, and lost brackets. Five errors, five fixes, and a validator that points at the exact line. Invalid JSON stops being a mystery once you know the list.
FAQ
Why is my JSON invalid?
Are comments allowed in JSON?
Why does JavaScript accept my object but JSON rejects it?
How do I find a missing bracket in a large JSON file?
Can a tool fix my JSON automatically?
Related Tools
About the Author
Huzaifa Umer writes practical guides on documents, file formats, and everyday web tools at The Tools Kit. He focuses on plain answers that save readers time.
View all posts by Huzaifa Umer →