“Unexpected token” in JSON: what it means and how to fix it

TL;DR: Make the JSON strict, validate locally, then export/convert (no upload).

This error is a clue: JSON.parse saw a character that’s not allowed at that position. The fix is usually fast once you locate the exact token.

What the message is telling you

JSON is strict. At each position, only certain characters are valid (quotes, digits, braces, commas, whitespace). “Unexpected token X” means the parser found X where it expected something else.

How to find the breaking character

  • Use the reported position (or line/column) to jump to the spot.
  • Inspect 10–20 characters around the position.
  • Look for a stray quote, trailing comma, or unescaped character.

Top causes (real-world)

  • Single quotes (') used for strings or keys.
  • Trailing commas before } or ].
  • Unquoted keys ({a:1} is JavaScript, not JSON).
  • Extra text copied from logs (timestamps, prefixes).

Fix safely (no-upload)

If the payload contains tokens, emails, or customer data, avoid online validators. Use a local validator that runs entirely in your browser.

Trust note: All processing happens locally in your browser. Files are never uploaded.

Practical checklist (fast)

If you’re stuck, use this quick checklist to narrow the problem before you try “random fixes”. Start by validating the input format (syntax first), then confirm shape expectations (array vs object, headers vs rows). Convert a small sample, inspect the output, and only then export the full result.

  • Validate: confirm the input is strict JSON/XML/CSV (no stray characters).
  • Confirm shape: arrays vs objects; headers vs row lengths; repeated tags vs arrays.
  • Test a sample: first 20–50 rows/items are enough to detect parsing issues.
  • Export: copy/download the output and re-check it in the consumer (script/spreadsheet/API).

This workflow is privacy-first by design: All processing happens locally in your browser. Files are never uploaded.

FAQ

Does “Unexpected token o” mean “object” is wrong? Not exactly. It often means you pasted JavaScript or a log string instead of JSON.

Can whitespace cause this? Whitespace is allowed. The unexpected token is typically a non-whitespace character.

Privacy & Security
All processing happens locally in your browser. Files are never uploaded.