Home/Guides/Fix JSON unexpected token (API and webhook payloads)

Fix JSON unexpected token (API and webhook payloads)

An unexpected token error means the JSON parser hit a character it cannot interpret at that position—often a trailing comma, single-quoted key, or truncated body. Webhooks and APIs that return non-JSON error pages also surface as this error. Pinpoint the exact line before fixing upstream.

Common causes

  • Trailing comma after the last property.
  • Unquoted keys or single quotes instead of double quotes.
  • Cut-off body from a proxy or gzip issue.

How to fix

  • Validate the raw body with Request Body Validator before parsing in app code.
  • Remove trailing commas and quote keys with double quotes.
  • Log raw bytes for webhooks to see the true payload.

Use our tool

Validate JSON body