Debugging API Response JSON
When an API call fails with a JSON parse error, the first thing to check is whether the response is actually valid JSON. Common issues include HTML error pages returned instead of JSON (your server returned a 500 page), truncated responses from timeout or buffer limits, and mixed content like a BOM (byte order mark) prepended to the JSON.
Our validator parses the input and either confirms it's valid or shows the exact position of the first error. This is faster than adding try/catch around JSON.parse() in your code and reading the error message — paste the response here and see the problem immediately.
This is particularly useful when debugging webhook payloads, third-party API integrations, and microservice communication. If one service returns malformed JSON, downstream services fail silently or throw cryptic errors. Validate the raw response to isolate the source of the problem.
Tips
- If you see
Unexpected token < at position 0, the response is HTML, not JSON — check the HTTP status code. - Some APIs return JSONP (JSON with a function wrapper) — strip the function call before validating.
- Check the
Content-Typeheader. If it's notapplication/json, the server might be returning something else. - For truncated responses, check your HTTP client's timeout and buffer size settings.