Debugging JSON Errors Without the Guesswork
A JSON parse error blames a character, not a line. Here are the four shapes behind almost all of them, and the one habit that fixes all four at once.

Mark Steven • Content Writer

I spent enough evenings reading parse errors to know what they are actually telling you, and that is what this post is for. A parse error is a statement about the character the parser choked on. It is not a diagnosis of the line that is wrong.
The gap between those two things is the whole problem. The character is legal on its own, so the real mistake is almost always somewhere just before the reported position. Four shapes account for nearly every error you will meet.
1. The trailing comma
By a distance the most common, and the one that reads most like nonsense. A comma after the last member of an object or the last element of an array is invalid, and every strict parser rejects it:
{
"name": "Toolezs",
"category": "students",
}The parser stops at the closing brace because it was expecting another key or another value. Note where the blame lands: the } is fine, the character before it is not. Delete the comma and the file parses. This is also the shape you get for free from a language that allows trailing commas, because something in the pipeline serialised it and nobody looked.
2. Single quotes
JSON has exactly one string delimiter and it is the double quote. Python, JavaScript, and YAML all write single quotes by default, so data that started life in one of them and got copied into a .json file arrives with quotes the parser will not accept at the very first key.
This one is easy to spot because the failure is immediate and at the top of the file, which is unusual. A parse error that points at line 1 almost always means the document is not JSON at the first character.
3. Unquoted keys, and bare words that are not true, false, or null
Every key is a string, so every key needs quotes. And the only bare words JSON knows about are true, false, and null; every other unquoted token is an error:
{
"enabled": true,
"retries": 3,
"label": null
}Watch for the capitalised variants too. True, False, None, and nil are all rejected, and those are exactly what you get after a round trip through Python where null is written None. If a file parses on your machine and fails in production, this is the first thing to check.
4. Comments
JSON has no comment syntax. // and block comments are not part of the format, and a parser that accepts them is being lenient in a way that will bite you later when something stricter reads the same file.
If you genuinely need comments, use JSONC and name the file honestly. A .json extension on a file with comments is a trap you are setting for the next person, and that person is usually you in six months.
The habit that fixes all four
Look one line above the reported position. It is wrong four times out of five.
That is genuinely the whole method. The reported position is a wall you hit, not the wall that was built, and walking back one or two lines puts you in the region where the damage is. With the four shapes above in your head you will usually have it in under a minute.
Knowing the exact line and column a parse failed at is what makes the loop fast: paste, read the position, look up, fix, paste again. It is less clever than it sounds, which is the point.
Toolezs

