Unexpected Token at Position 0
Back to Tools
SyntaxError: Unexpected token < in JSON at position 0
This is arguably the most common JSON parsing error in JavaScript. It occurs when `JSON.parse()` attempts to parse a string that is not valid JSON, typically HTML or plain text starting with an unexpected character (like `<` from an HTML tag).
Common Causes
- •The API endpoint returned a 404/500 HTML error page instead of JSON.
- •The response was intercepted by a proxy or firewall returning HTML.
- •You are trying to parse undefined or null as a string natively.
- •The file encoding contains a Byte Order Mark (BOM).
What Triggers It
<!DOCTYPE html>
<html>
<body>
<h1>Error 404 Not Found</h1>
</body>
</html>How to Fix It
{
"error": "Not Found",
"status": 404
}The Solution
First, check the raw response payload in your browser DevTools Network tab. Ensure the server is sending the `Content-Type: application/json` header and that the response body is strictly JSON. If you are reading a file, strip the BOM or ensure it is saved as standard UTF-8.
Fix Your JSON Automatically
Paste your broken JSON code into our free online tool to repair syntax errors instantly.