JSON Debugging Sheet
What JSON allows, what it forbids, and how to translate a parser error into the character that caused it.
BFCBrilliance · bfcbrilliance.com/tools/json-formatter
The five things that break JSON
- Trailing comma
- {"a":1,} — reads as 'expected property name'
- Single quotes
- {'a':1} — strings need double quotes
- Unquoted key
- {a:1} — keys must be quoted strings
- Comments
- // and /* */ are not JSON
- Raw line break
- inside a string — escape it as \n
What JSON actually allows
- Types
- object, array, string, number, true, false, null
- No
- undefined, NaN, Infinity, dates, functions
- Numbers
- no leading +, no leading zeros, no hex
- Strings
- double quotes only, backslash escapes
- Top level
- any value — not just an object or array
- Key order
- preserved in practice, not guaranteed by spec
Finding the break
- Read the position in the error - then look at the character BEFORE it
- The message says what the parser EXPECTED, not what you got wrong
- 'Expected property name' after a comma = trailing comma
- Check the LAST item of every object and array
- Search for single quotes
- Search for // and /*
- Check anything pasted from a spreadsheet for smart quotes
- Check strings that span lines - the break must be escaped
- If it came from JavaScript, remember JS is far more forgiving than JSON
The error IS the output
When the document does not parse, both boxes show the parser's own message rather than failing silently. That message names what it expected and where it stopped - which, once you know it points just past the mistake rather than at it, is usually enough to find the character responsible in a few seconds.
Careful what you paste anywhere
This runs entirely in your browser and uploads nothing. Not every online JSON tool does, and the things people paste into them are frequently production API responses and config files with credentials still in them. Worth a habit of checking before pasting, wherever you are.