The “Unexpected token … in JSON” error means the parser hit a character it did not expect for valid JSON. It is one of the most common errors from JSON.parse(), response.json(), and fetch.
Unexpected token < in JSON at position 0Unexpected token o in JSON at position 1Unexpected token 'x', "…" is not valid JSONAlmost always, the text you are parsing is not JSON at all. Unexpected token < in JSON at position 0 is the classic tell: the very first character is <, so you are parsing an HTML page (a login redirect, a 404, or a server error page) instead of a JSON response. Other variants — Unexpected token o (the word [object Object]), a stray letter, or a leading byte-order mark — mean a stray or wrong character is sitting where JSON syntax expected a value.
Log the raw response body before parsing and look at the first characters. If it starts with <!DOCTYPE or <html>, fix the request (wrong URL, auth redirect, or an error status) rather than the JSON. If it is genuine JSON with one bad character — a smart quote, a trailing comma, an unquoted key, or a leading BOM — paste it into the validator below to jump straight to the offending line and column.
The validator below runs entirely in your browser and flags the exact line and column of the first error.
Position 0 is the first character. A < there means the response is HTML, not JSON — usually an error page, a redirect to a login screen, or a 404 returned where you expected JSON. Inspect the raw response and fix the request.
You very likely called JSON.parse on a value that is already a JavaScript object. Coercing it to a string yields "[object Object]", and the parser trips on the o at position 1. Do not JSON.parse something that is already parsed.
Paste the JSON into the validator on this page — it reports the precise line and column of the first unexpected token so you can delete or fix that character.