What is a JSON parse error? (decoder cheatsheet)

Getting Unexpected token or failed to parse JSON? Match the exact error text below, apply the fix, then re-validate your payload.

Common JSON.parse errors decoded

Error messageUsually meansQuick fix
Unexpected token < in JSON at position 0You parsed HTML (often an error page) instead of JSON.Inspect response body/status. Verify endpoint and Content-Type before JSON.parse.
Unexpected token ' in JSON at position ...Single quotes were used in keys/strings.Use double quotes for keys and string values.
Unexpected token } / ] in JSON at position ...Trailing comma or malformed structure.Remove trailing commas and re-check object/array nesting.
Unexpected end of JSON inputTruncated payload or empty response.Check server output length, buffering, and whether body is empty.
Unexpected number in JSON at position ...Missing comma between fields/array values.Add commas between adjacent values.

Copy-ready debug checklist

  1. Log raw response text before parsing.
  2. Check HTTP status and Content-Type.
  3. Validate payload in a JSON formatter.
  4. Fix structure (quotes, commas, braces) and re-test.