Debugging API JSON Responses: Tools and Techniques
Debugging JSON from APIs is one of the most common and most frustrating tasks in software development. A minified 50 KB response, a token that keeps failing to decode, a field that shows up as null when you expected a value — these issues waste hours without the right tools. This guide covers the complete toolkit for inspecting and debugging API JSON, from browser DevTools to the command line to purpose-built web tools.
Browser DevTools: Network Tab
The browser's built-in Network tab is the first stop for debugging API responses during web development.
- Open DevTools (F12 or Cmd+Option+I)
- Click the Network tab
- Filter by Fetch/XHR to see only API requests
- Click a request to open the inspector
- Click the Response tab to see the raw JSON
- Click Preview for a formatted, collapsible tree view
The Preview tab in Chrome and Firefox DevTools renders JSON in an interactive tree — you can expand objects, copy values, and search. It is fast and always available, but limited for complex debugging tasks: no querying, no diffing, no schema validation.
curl + jq: The Terminal Workflow
curl fetches the API response; jq processes and formats the JSON. Together they are the standard command-line debugging workflow.
# Pretty-print the response
curl -s https://api.example.com/users | jq '.'
# Add authentication headers
curl -s -H "Authorization: Bearer $TOKEN" https://api.example.com/users | jq '.'
# Extract specific fields
curl -s https://api.example.com/users | jq '[.[].email]'
# Filter by condition
curl -s https://api.example.com/users | jq '[.[] | select(.role == "admin")]'
# Save response to file and inspect
curl -s https://api.example.com/data -o response.json
jq '.' response.json
# Count array items
curl -s https://api.example.com/users | jq 'length'
# Get unique values
curl -s https://api.example.com/orders | jq '[.[].status] | unique'
Postman and Insomnia
GUI HTTP clients like Postman and Insomnia provide a complete request-building and response-inspection environment:
- Build and save requests with headers, authentication and body
- See formatted response JSON with collapsible tree
- Search within the response
- Write test scripts to assert on response values
- Create collections of related requests for an API
Postman is best for comprehensive API testing workflows. For lightweight, privacy-conscious API inspection, both Postman and Insomnia send telemetry by default — check their privacy settings.
The IRJSON Debugging Workflow
For complex JSON debugging tasks, IRJSON provides a complete toolkit in a single browser tab with 100% privacy — no data leaves your device.
Step 1: Format with the JSON Formatter
Copy the raw API response from DevTools or curl, paste it into IRJSON, and press Ctrl+Enter. The minified response is instantly formatted with syntax highlighting, tree view and stats. The Stats tab shows total node count, nesting depth and byte size — immediately useful for understanding a large response.
Step 2: Extract Data with JSONPath Query
Use IRJSON's Query tool to extract specific values without manually navigating a large tree. Write a JSONPath expression like $.users[?(@.role == "admin")].email to get exactly what you need instantly.
// Useful JSONPath patterns for API debugging
$.data[*] // all items in a data array
$..id // all id fields at any depth
$.users[?(@.active == true)] // filter active users
$.errors[0].message // first error message
$..createdAt // all timestamps
Step 3: Diff Against Expected Response
When the API returns something unexpected, use IRJSON's Diff tool to compare the actual response against what you expected. Additions, deletions and modifications are highlighted immediately. This is invaluable for catching API versioning issues and unexpected field name changes.
Step 4: Validate Against Schema
If you have a JSON Schema for the API response (from OpenAPI/Swagger), validate the actual response against it using IRJSON's Schema Validator. AJV-powered validation reports every constraint violation with exact paths — immediately identifying missing required fields, wrong types, or invalid enum values.
Step 5: Decode JWT Tokens
API responses often include JWT tokens (access tokens, refresh tokens, ID tokens). Use IRJSON's JWT Decoder to inspect the claims, check the algorithm, and verify the expiry — entirely in your browser with no server contact.
Step 6: Repair Malformed Responses
Some APIs return malformed JSON — especially older systems, AI-generated responses, or log-tailing tools that truncate output. Use IRJSON's Repair tool to automatically fix trailing commas, single quotes and other common errors before debugging the data.
Common API JSON Bugs
| Bug Type | Symptom | How to Detect |
|---|---|---|
| Extra nesting | response.data.data instead of response.data | Tree view in IRJSON |
| Wrong type | id is a string instead of number | Schema validation |
| null vs missing | Field is null vs absent entirely | Diff against expected |
| snake_case vs camelCase | user_id instead of userId | JSONPath query for both |
| Timestamp format | Unix epoch instead of ISO 8601 | Stats tab + tree view |
| Pagination | Only first page returned, not all | length() query |
Frequently Asked Questions
How do I pretty-print a curl response?
Pipe through jq: curl -s https://api.example.com/data | jq '.'. The -s flag suppresses curl's progress meter. jq formats the JSON with colour highlighting in the terminal.
How do I extract a specific field from JSON in the terminal?
Use jq with a path expression: jq '.users[0].email' response.json. For all items in an array: jq '[.[].email]' response.json. You can also test these expressions in IRJSON's browser-based query tool first, then copy them to your terminal.
What is the best tool for viewing API JSON?
For browser-based inspection, IRJSON is the most complete tool: it formats, validates, queries, diffs, decodes JWTs and repairs broken JSON in one place with 100% privacy. For command-line work, jq is the standard. For GUI HTTP clients, Postman and Insomnia are both excellent for request building and testing.
Debug API responses in your browser — free
Paste any JSON response into IRJSON to format, query, diff, validate and decode JWTs. 100% private, no sign-up.
Open IRJSON Free →