JSON syntax, and where it usually breaks
JSON is deliberately tiny: objects { }, arrays [ ], strings in double quotes, numbers, and the literals true, false, and null. That strictness is exactly why it trips on the small things humans do out of habit:
- Trailing commas —
[1, 2, 3,]is invalid JSON (it is valid JavaScript, which is the usual source of the confusion). - Single quotes — keys and strings must use
"double"quotes. - Comments — JSON has none;
//and/* */are errors. - Unquoted keys —
{name: "x"}must be written{"name": "x"}.
This validator points at the exact line, column, and character so you fix the cause rather than guess, then lets you beautify (indent for reading) or minify (strip whitespace for the wire). Everything runs in your browser — nothing is uploaded.
Related
- YAML Validator — convert between YAML and JSON.
- Insomnia as an API remote control — where JSON request bodies come from.