How does this error differ from a "SyntaxError: Unexpected token X in JSON at position Y" where X is not '<'?

Responsive Ad Header

Question

Grade: Education Subject: Support
How does this error differ from a "SyntaxError: Unexpected token X in JSON at position Y" where X is not '<'?
Asked by:
112 Viewed 112 Answers
Responsive Ad After Question

Answer (112)

Best Answer
(499)
While both are `SyntaxError`s during JSON parsing, the specific "unrecognized token '<'" is highly indicative of the parser receiving *entirely different content* (HTML/XML) than expected. Other unexpected tokens (like `u`, `U`, `_`, etc.) usually mean the parser received something *intended* to be JSON but was malformed (e.g., unquoted keys, trailing commas, incorrect boolean values like `Undefined` instead of `undefined`). The '<' specifically points to a complete content type mismatch.