How to Fix the Most Common JSON Errors
Developer · October 2, 2026 · 1 min read
JSON looks like JavaScript, which is why so many people write invalid JSON by accident. Parsers are strict: one wrong character and the whole document is rejected. These are the mistakes that cause most errors.
1. A trailing comma
JavaScript allows a comma after the last item, JSON doesn't.
{ "name": "Ann", "age": 30, } (wrong)
{ "name": "Ann", "age": 30 } (right)2. Single quotes
Strings and keys must use double quotes.
{ 'name': 'Ann' } (wrong)
{ "name": "Ann" } (right)3. Unquoted keys
{ name: "Ann" } (wrong)
{ "name": "Ann" } (right)4. Comments
JSON has no comments. Remove // and /* */ lines, or store notes in a normal field such as "_comment".
5. Missing commas or brackets
Every item in an object or list is separated by a comma, and every { and [ needs a matching closing character. Long documents hide a missing bracket easily.
6. Special values and unescaped characters
undefined,NaNandInfinityaren't valid values. Usenullor a string.- A line break inside a string must be written
\n, and a quote inside a string must be written\". - A backslash must be doubled:
"C:\\temp". - Numbers can't have leading zeros (
007) or a trailing dot (1.).
Reading the error message
Error messages give a line and column. The reported spot is where the parser gave up, which is sometimes just after the real mistake. If the message points at the start of a key, look at the end of the line before it for a missing comma.
How to fix it
- Paste the JSON into the JSON Formatter.
- Read the line and column it reports and fix that one problem.
- Repeat until it says "Valid JSON", then click Prettify.
- Compare the fixed version with the original using JSON Diff if you want to be sure nothing else changed.