JSON errorUnexpected tokenJSON repairJSON validation

How to Fix JSON Unexpected token Errors

Unexpected token usually means the JSON parser found a character that is not valid at that position, such as a trailing comma, comment, single quote, or HTML response.

Published July 2, 2026 · 7 min read

Unexpected token means the parser reached a character that should not appear at that point in valid JSON.

You may see this in JSON.parse, API debugging, config imports, or validation tools. The character in the message matters: Unexpected token }, Unexpected token o, and Unexpected token < usually point to different root causes.

The Most Common Cause: A Trailing Comma

{
  "name": "Tom",
  "age": 18,
}

Standard JSON does not allow a comma after the final object property or array item.

{
  "name": "Tom",
  "age": 18
}

What Different Tokens Often Mean

Error messageCommon causeHow to fix it
Unexpected token }Trailing comma or missing valueCheck object and array endings
Unexpected token oParsing an object again as JSON textMake sure JSON.parse receives a string
Unexpected token <The response is HTMLCheck the API URL, auth state, or server error page
Unexpected token /The JSON contains commentsRemove line or block comments
Unexpected token nPython-style NoneUse JSON null instead

A Practical Debugging Order

  1. Confirm the content is JSON, not HTML, logs, or plain text.
  2. Check for comments, trailing commas, single quotes, and unquoted keys.
  3. Look for Python-style True, False, or None values.
  4. If it came from an API, inspect the HTTP status code and response headers.
  5. Format the fixed JSON to confirm the structure is complete.

Summary

Unexpected token is not one single bug. It is a parser signal. Start with the reported character, then verify the source data and syntax rules.