Unexpected Token < in JSON: What It Means and How to Fix It
A less-than sign at the beginning of a supposed JSON response usually means the body is actually HTML. Common sources are 404 pages, authentication redirects, reverse-proxy errors, framework error screens, or a server route returning markup.
What this JSON error means
SyntaxError: Unexpected token '<' ... is not valid JSONDo not start by changing JSON.parse. Inspect the raw HTTP status, Content-Type header, final response URL, and first characters of the response body. Fix the endpoint or server behavior that returned HTML.
Broken JSON vs. corrected JSON
Compare the invalid syntax with a corrected version before applying the same change to your payload.
Invalid JSON
<!doctype html><html><body>404 Not Found</body></html>
Valid JSON
{"error":"not_found","status":404}Common causes of this JSON error
- ●API endpoint returned an HTML 404 page
- ●Authentication redirected the request to a login page
- ●Reverse proxy or CDN returned an HTML error document
- ●Frontend requested the wrong URL
- ●Server crashed and returned a framework error page
Fix and validate your JSON
After correcting the suspected syntax, run the complete payload through a validator. If it still fails, use the diagnostic tool to locate the next parser error before formatting the final JSON.
Related JSON errors
JSON Unexpected Token Error
Understand and fix JSON unexpected token errors. See broken and corrected examples, common causes, and a fast workflow for finding the exact invalid character.
Unexpected End of JSON Input
Fix “Unexpected end of JSON input” errors caused by truncated JSON, missing braces or brackets, incomplete strings, and empty API responses.
Trailing Comma in JSON
Learn why trailing commas are invalid in standard JSON and fix objects or arrays copied from JavaScript, TypeScript, JSON5, or configuration files.
Single Quotes in JSON
Fix invalid JSON that uses single quotes. JSON requires double quotes around property names and string values.
JSON Property Names Must Be Double-Quoted
Fix JSON with unquoted object keys. Standard JSON requires every property name to be enclosed in double quotes.
Invalid Escape Character in JSON
Fix invalid JSON escape sequences in Windows paths, regex strings, copied text, and backslash-heavy values.
JSON error FAQ
What does Unexpected Token < in JSON mean?
A less-than sign at the beginning of a supposed JSON response usually means the body is actually HTML. Common sources are 404 pages, authentication redirects, reverse-proxy errors, framework error screens, or a server route returning markup.
How do I fix Unexpected Token < in JSON?
Do not start by changing JSON.parse. Inspect the raw HTTP status, Content-Type header, final response URL, and first characters of the response body. Fix the endpoint or server behavior that returned HTML.