EthicalFusion

The 7 Most Common JSON Errors (and How to Fix Them Fast)

Guides · Jun 4, 2026 · 1 views

"Unexpected token at position 247" has ruined more developer afternoons than any other error message. The good news: about 90% of JSON parse failures come from the same seven mistakes. Paste your JSON into the free JSON validator to find the position, then check this list.

1. Trailing commas

{"a": 1, "b": 2,} — legal in JavaScript objects, fatal in JSON. The comma after the last item has to go. This is the single most common error, especially in hand-edited config files.

2. Single quotes

JSON requires double quotes for both keys and string values. {'name': 'asef'} fails; {"name": "asef"} parses. Python developers hit this constantly because Python's dict repr uses single quotes.

3. Unquoted keys

{name: "asef"} is a JavaScript object literal, not JSON. Every key needs double quotes.

4. Comments

JSON has no comment syntax. // this breaks and /* this too */ must be stripped — which is painful in config files, and why formats like JSONC and YAML exist.

5. Truncated data

"Unexpected end of input" almost always means the JSON was cut off — a copied API response that hit a console length limit, or a partial network read. Check that braces and brackets balance; the JSON formatter makes unbalanced structures visually obvious.

6. Unescaped characters in strings

Literal newlines, tabs and double quotes inside a string must be escaped: \n, \t, \". This bites anyone pasting multi-line text into a JSON field.

7. It was never JSON

The sneakiest one: your "JSON response" is actually an HTML error page (a 404, a login redirect, a Cloudflare challenge). If the error is at position 0 with token <, you're parsing HTML. Print the raw response before blaming the parser.

The 30-second debug loop

Format → read the error position → fix → revalidate. For data work, the JSON to CSV and CSV to JSON converters handle the next step once your JSON finally parses.

#json#developers#debugging

Related articles