Home / JSON Error Fixes / Unexpected Token in JSON

Unexpected Token in JSON: How to Fix It

This error usually means you are parsing non-JSON content as JSON, or your payload is malformed before parse time. Use this workflow to isolate source and fix quickly.

Fast Diagnosis Checklist

  • Inspect raw response body before calling JSON.parse or response.json().
  • Confirm content-type is application/json.
  • Run payload through JSON Validator.
  • Reformat payload in JSON Formatter to locate breakpoints.

Common Root Causes

  • Server returned HTML error page (< token at position 0).
  • Trailing commas or missing quotes in JSON body.
  • Double-encoded escaped JSON string not decoded first.
  • Unexpected BOM or invisible characters at payload start.

Recommended Workflow

Validate syntax first, then compare expected vs actual response shape using JSON Diff. If the source is CSV/XML conversion output, normalize via conversion guides before parsing.

Explore More SEO Hubs