How to Debug API JSON Responses Step by Step
Capture the raw response, read the status code, format and validate the JSON body, explore it, compare it with a working response and share it safely.
By jsonbody.com Team ·
When an API call fails or returns surprising data, the answer is almost always in the response: the status code, the headers or the JSON body. Here is a step-by-step routine for debugging JSON API responses quickly.
1. Capture the raw response
Get the exact request and response before changing any code:
- In the browser, open DevTools, go to the Network tab, click the request and look at Response and Headers. Right-click it and choose Copy as cURL to replay it.
- Replay the request in the REST API Tester to see the status, timing, headers and body together.
- Turn a copied cURL command into code for your language with cURL to Code.
2. Read the status code first
The status code tells you where to look:
- 2xx but wrong data: the problem is in the body or your parsing.
- 4xx: your request is wrong, such as a missing token (401), missing permission (403) or invalid body (400 or 422).
- 5xx: the server failed. Check its logs, or retry later for 502, 503 and 504.
Look up any code in HTTP Status Codes, and read HTTP status codes every developer should know.
3. Format and validate the body
Minified JSON hides problems. Paste the body into the JSON Parser and click Format. If the API returned invalid JSON, Validate shows the line and column of the problem. Common causes:
- An HTML error page returned instead of JSON, often from a proxy or a 404.
- A truncated response because of a timeout.
- A JSON string inside a JSON string, such as
"{\"id\":1}". Unwrap it with JSON Escape / Unescape or the API Response Formatter.
4. Explore the structure
Large responses are easier to understand as a tree. Use the Tree View in the JSON Parser or the JSON Viewer to expand only the parts you need, search for a key, and copy the exact path of a value. Pull out specific values with the JSONPath Tester.
5. Compare with a working response
If something used to work, compare today's response with an older one in JSON Compare or the Diff Checker, which can ignore key order. Look for:
- Renamed or missing fields.
- Types that changed, such as a number that is now a string.
nullwhere you expected an object or array.
6. Check the headers
Content-Type should be application/json. Caching headers can explain stale data, and CORS headers explain browser-only failures. Inspect them with the HTTP Headers Checker.
Work safely with API responses
- Remove secrets before sharing a response: tokens, cookies, API keys and personal data.
- Prefer tools that process data in your browser. The jsonbody.com JSON tools do, and your JSON is only sent to our server when you choose to save or share it.
- Decode tokens with the JWT Debugger rather than pasting them into unknown sites.
- When you need to share a response with your team, use a share link or a shared group.
Quick checklist
- Status code and headers.
- Formatted and validated body.
- Structure explored and values located.
- Compared with a known-good response.
- Secrets removed before sharing.