How to Fix JSON Parse Error: Unexpected Token
The "unexpected token" error is the most common JSON parsing mistake. It usually means a comma in the wrong place, an unclosed bracket, or an invalid character. This guide shows you how to locate and fix unexpected token errors quickly.
Common causes
- Trailing comma after the last array element or object property.
- Missing comma between array elements or object properties.
- Unclosed bracket or brace—an extra { or [ without a matching } or ].
- Invalid character: BOM, null bytes, or non-printable characters in the string.
- Single quotes instead of double quotes (JSON requires double quotes).
How to fix
- Use the JSON Validator: paste your JSON and get the exact line and column of the error.
- Remove trailing commas before } or ]; JSON does not allow them.
- Ensure every { has a matching }, every [ has a matching ], and all strings use double quotes.
- Check for hidden characters: copy the JSON into a fresh editor or use the validator's error message.
- Validate API responses before JSON.parse() in production to catch errors early.
Use our tool
Open JSON Validator