Common JSON errors and how to fix them
Real error messages from Chrome, Node.js and Python for the most common JSON mistakes — what causes each one and how to fix it.
- Trailing comma in JSON: "Expected double-quoted property name"
Why a comma after the last item breaks JSON, the exact error messages in Chrome, Node.js and Python, and how to fix it.
- Single quotes in JSON: "Expected property name or '}'"
JSON only accepts double quotes. See the exact Chrome, Node.js and Python errors for single-quoted strings and how to convert them.
- Unquoted keys in JSON: "Expected property name or '}'"
JSON keys must be wrapped in double quotes. Exact error messages and the fix for {name: "Kim"}-style objects.
- Comments in JSON: why // and /* */ cause errors
JSON has no comment syntax. See the errors comments produce in Chrome, Node.js and Python and the alternatives you can use.
- Missing comma in JSON: "Expected ',' or '}' after property value"
How to find the missing comma between two JSON items, with the exact error messages from Chrome, Node.js and Python.
- "Unexpected end of JSON input": causes and fixes
The JSON ended before every { and [ was closed. Common causes such as truncated or empty responses, and how to fix them.
- "Bad control character in string literal": line breaks inside JSON strings
JSON strings cannot contain raw line breaks or tabs. See the errors in Chrome, Node.js and Python and how to escape them.
- "Bad escaped character" in JSON: backslashes in Windows paths
Why C:\Users breaks JSON, the exact error messages in Chrome, Node.js and Python, and how to escape backslashes.
- True, None and NaN in JSON: "Unexpected token" errors
Python True/False/None and JavaScript NaN/undefined are not valid JSON. Exact error messages and the correct values to use.
- Big numbers in JSON lose precision: 12345678901234567890 becomes 12345678901234567000
Why JSON.parse rounds large integers such as IDs, how to spot it, and safe ways to keep every digit.
- "Unexpected token '<'" in JSON: the server returned HTML
Unexpected token < at position 0 means you received HTML, not JSON. Common causes (404, 500, login pages) and how to debug them.