Quick answer
Many APIs return JSON.
API Response Invalid JSON
Many APIs return JSON. If the response body is not valid JSON (e.g. truncated, malformed, or HTML error page), parsers will fail. Use a checker to get the exact line and column.
Common causes
- Server returned an error page (HTML) instead of JSON.
- Response was truncated or cut off mid-stream.
- Trailing comma, wrong quotes, or invalid escape in the body.
How to fix
- Validate the response body with an API response checker to get line/column.
- Ensure the API returns Content-Type: application/json and a complete body.
- Check for trailing commas, single quotes, or unescaped characters in the body.
Examples
Bad
{"id": 1, "name": "test",}Good
{"id": 1, "name": "test"}FAQ
- Why is my API response not valid JSON?
- Often the server returned HTML (error page), or the body was truncated. Validate the raw body to see the exact error.
- Can I paste a full HTTP response?
- Yes. The checker extracts the body after the blank line and validates the JSON part.
Fix it now
Try in validator (prefill this example)