HomeBlog › The 7 Most Common JSON Errors (And How t…
developer

The 7 Most Common JSON Errors (And How to Fix Every One)

May 5, 20266 min readBy My ToolKit

Why JSON errors are so frustrating

JSON syntax is unforgiving. A single missing comma, an extra bracket, or a stray comment can break an entire API payload, config file, or database export. And the error messages are notoriously unhelpful — "Unexpected token at position 847" tells you almost nothing useful.

I've formatted and debugged thousands of JSON files using my own tool. Here are the seven errors that appear most often, why they happen, and exactly how to fix them.

Error 1: Trailing comma

This is the single most common JSON error. It looks like this:

{"name": "Claude", "version": 4,}

That comma after 4 is valid JavaScript — but invalid JSON. JSON does not allow trailing commas after the last item in an object or array. The fix: remove the final comma.

Error 2: Single quotes instead of double quotes

JavaScript developers often write:

{'name': 'Claude'}

JSON requires double quotes everywhere — for keys and string values. Single quotes are not valid JSON. The fix: replace all ' with ".

Error 3: Unquoted keys

This works in JavaScript object literals but not in JSON:

{name: "Claude", version: 4}

Every key in a JSON object must be a quoted string. The fix: wrap all keys in double quotes.

Error 4: Comments

JSON does not support comments. Neither // this nor /* this */ is valid. If you're maintaining a config file with comments, you have a few options: use JSONC (JSON with Comments) which some tools support, use a different format like YAML or TOML, or move comments to a separate documentation file.

Error 5: Unclosed brackets or braces

Every opening [ needs a closing ], and every opening { needs a closing }. When you have deeply nested JSON, it's easy to lose count. My JSON formatter highlights mismatched brackets and tells you exactly where the mismatch occurs.

Error 6: Undefined, NaN, or Infinity values

These are valid JavaScript values but illegal in JSON:

{"result": undefined, "score": NaN, "limit": Infinity}

JSON only supports: strings, numbers, booleans (true/false), null, objects, and arrays. Replace undefined/NaN with null or omit those fields entirely.

Error 7: Incorrect number formats

JSON numbers cannot have leading zeros (007 is invalid), cannot be expressed in hex (0xFF is invalid), and cannot use + prefix (+1 is invalid). Use standard decimal notation: 7, 255, 1.

The fastest way to catch all of these

Paste your JSON into my formatter and switch to Validate mode. It catches all seven of these errors instantly and points you to the exact position in the file where the problem is. No guesswork needed.

My JSON FormatterFree · runs in your browser · nothing uploaded
Open the tool →