Common JSON Errors and How to Fix Them
When JSON.parse fails, the message tells you where the parser gave up but not why. Each page below explains one error, lists its usual causes with broken and valid examples, and opens the tool with JSON that reproduces it so you can see exactly where it breaks. Messages are shown as Chrome, Edge and Node.js print them.
- Unexpected token '<' in JSON at position 0
Why JSON.parse says Unexpected token '<' (the response is HTML, not JSON), the five usual causes, and how to find out what your server really returned. - Unexpected end of JSON input
What "Unexpected end of JSON input" means: the JSON is empty or cut off. Find out why a response is empty or truncated and how to handle it safely. - Expected property name or '}' in JSON
Fix "Expected property name or '}' in JSON at position 1": caused by single quotes or unquoted keys. See how JavaScript objects and Python dicts differ from JSON. - Trailing comma in JSON
JSON does not allow a comma after the last item. See the exact error messages, why tsconfig and ESLint files differ, and how to remove trailing commas. - Expected ',' or '}' after property value in JSON
Fix "Expected ',' or '}' after property value in JSON": a missing comma, a comment or a merge conflict in your JSON. Includes the array version of the error. - "undefined" is not valid JSON
JSON.parse(undefined) and JSON.parse of an object both fail. Understand why, how to avoid double parsing, and how to guard against undefined input. - Bad control character in string literal in JSON
Fix "Bad control character in string literal" and "Bad escaped character": raw newlines, tabs and Windows paths inside JSON strings. Learn the escape rules. - Unexpected non-whitespace character after JSON
Why JSON.parse reports extra data after the JSON: concatenated objects, JSON Lines, an extra closing brace or trailing text. How to parse multiple documents. - Unexpected token 'N' or an invisible character in JSON
NaN, Infinity, undefined and a byte-order mark (BOM) are not valid JSON. See the errors they cause and how to export and read JSON correctly.
Not sure which error you have?
Paste your text into the JSON Validator. It shows the line and column of the first problem, and Fix JSON repairs the common mistakes automatically.