JSON error index

JSON Troubleshooting

Diagnose JSON parser errors, malformed payloads, escaping mistakes, truncated responses, and JavaScript values that are not valid JSON.

Diagnostic workflow

How to troubleshoot JSON problems

Start with the exact parser message and the smallest payload that still fails. JSON errors are usually caused either by invalid syntax in the document or by upstream code supplying the wrong kind of value, so separate those two cases before changing the data.

  • Check the reported line, column, or token first, then inspect the characters immediately before the failure instead of rewriting the whole document.
  • Confirm the input is actually JSON text rather than HTML, an already-parsed object, undefined, or multiple JSON documents joined together.
  • After each correction, validate again so the next parser error reflects the remaining problem rather than a chain reaction from the first mistake.

Browse focused fixes

Common JSON problems

36 troubleshooting pages

JSON troubleshooting

Unexpected Token in JSON – Find the Error

An unexpected token error means the parser found a character or value that cannot appear at that position in valid JSON. The reported token is often where the parser notices an earlier syntax mistake.

Read fix

JSON troubleshooting

Unexpected Token < in JSON – Why It Happens

A less-than sign at the start of a supposed JSON response usually means the body is HTML, not JSON. Check the raw response, status code, content type, redirects, and endpoint before trying to repair the payload.

Read fix

JSON troubleshooting

Missing Comma in JSON – Find and Fix It

JSON object properties and array items must be separated by commas. A parser often reports the next key or value as unexpected when the real mistake is a missing separator immediately before it.

Read fix

Understand the underlying concepts

2 related guides