A readable JSON response is easier to inspect, but formatting alone does not prove that an API response is valid or correct. This checklist shows how to use a JSON formatter and validator to diagnose syntax errors, unexpected data types, missing fields, escaped values, and differences between responses—while protecting tokens and personal data during debugging.
Overview
JSON is commonly used to carry request bodies, API responses, configuration values, and event payloads. Its structure is simple enough to read, but a small syntax mistake can make an entire response impossible for a parser to consume. Even valid JSON can still represent the wrong business data: a field may be missing, a number may arrive as a string, or an object may be returned where the client expects an array.
A JSON formatter online can add indentation, line breaks, and collapsible sections to a compact response. A JSON validator checks whether the text follows JSON syntax. These are useful first steps, not complete API tests. During debugging, separate three questions:
- Is the payload syntactically valid? Can a standard JSON parser read it?
- Does its shape match the contract? Are required fields, nesting, arrays, and data types present?
- Does the content explain the failure? Are values stale, empty, unauthorized, truncated, or different from what the client expects?
Use a formatter for readability, a validator for syntax, and an API or schema test for expected structure. For broader troubleshooting, the API debugging workflow guide connects formatted responses with request inspection, authentication checks, and error tracing.
Checklist by scenario
Scenario 1: You have a compact or unreadable response
- Copy the response body exactly as received. Do not remove characters before making a working copy.
- Check that the response is intended to be JSON. Confirm the content type when it is available; an HTML error page or plain-text message may be returned instead.
- Paste the copy into a trusted local formatter or an online formatter approved for the data sensitivity.
- Format the payload without changing values. Indentation should affect presentation, not content.
- Expand the top-level object or array and identify the fields relevant to the failing request.
- Record the request method, endpoint, status code, and a correlation or request identifier if one is available.
Formatting can immediately reveal a response that is an error object rather than the expected resource, or a nested field that was overlooked in a compact payload.
Scenario 2: The formatter reports invalid JSON
- Read the reported line and column, but inspect the surrounding lines too. The actual mistake may occur just before the location identified by the parser.
- Check commas between properties and array items. JSON does not allow a trailing comma after the final item.
- Check that property names use double quotes. Unquoted keys and single-quoted strings belong to some programming languages, but not standard JSON.
- Look for unescaped double quotes, line breaks, backslashes, or control characters inside string values.
- Confirm that values use JSON literals:
true,false, andnullare valid; language-specific values such asundefinedare not. - Run the corrected copy through a parser again. Keep the original response unchanged for comparison.
Do not “repair” a production response and then treat the repaired version as evidence. A corrected sample is useful for isolating a parser issue, but the original payload is what should be attached to a reproducible bug report after sensitive values are redacted.
Scenario 3: The JSON is valid, but the client still fails
- Compare the actual top-level type with what the client expects: object and array are not interchangeable.
- Check required fields, field names, capitalization, and nesting.
user_id,userId, anduser.idare different shapes. - Inspect data types. A string containing
"42"may not behave like the number42; a nullable field may not be safe to use as a string. - Check whether an empty array, empty object, or
nullhas a valid meaning in the client. - Compare date, time, decimal, and identifier values with the format expected by the consuming code.
- Review status handling. A syntactically valid error payload can arrive with a non-success status and should not be decoded as a normal resource.
When the response shape is central to the issue, compare it with the API documentation or a schema test. The guide to building better API documentation is useful when examples and field requirements need clarification.
Scenario 4: Two responses appear different
- Format both responses using the same indentation and ordering settings.
- Compare status codes, headers relevant to representation, and the response body—not just the visible values.
- Determine whether property order is the only difference. Object key order should not normally be treated as a data change.
- Check for differences in missing fields versus fields set to
null, and in empty collections versus absent collections. - Normalize only what is safe to normalize, such as whitespace or formatting. Do not hide differences in numbers, strings, types, or nested values.
- Capture the request inputs and environment details needed to reproduce the comparison.
A structural diff is usually more useful than a plain text diff because it can highlight changed paths and data types. For database-backed endpoints, format the related query separately and keep its parameters visible; see the SQL formatter and database debugging guide.
What to double-check
Common parser errors and practical fixes
| Parser message or symptom | Likely cause | What to check |
|---|---|---|
| Unexpected token at a property | Missing comma or invalid key syntax | Check the previous property and confirm the key is double-quoted. |
| Unexpected end of input | Truncated payload or missing closing bracket | Check whether the response was cut off and balance {} and []. |
| Unexpected character after JSON | Extra text, a second payload, or an appended log message | Inspect the response after the closing object or array. |
| Invalid escape sequence | Backslash used incorrectly inside a string | Check escaped quotes, backslashes, and newline characters. |
| Valid JSON, wrong application behavior | Schema, type, or semantic mismatch | Compare required fields, types, nullability, and business rules. |
Escaped values and nested JSON
Some APIs return JSON inside a string. For example, a field may contain "{'status':'ok'}" rather than a nested object. The outer response is valid, but the inner value requires a second parsing step. Confirm whether the field is intentionally serialized or has been encoded unexpectedly. Similarly, HTML entities, URL encoding, and Base64 are not interchangeable with JSON formatting. Decode only when the API contract or application code indicates that decoding is expected.
Privacy checklist for online formatters
- Remove or replace access tokens, refresh tokens, cookies, API keys, session identifiers, and authorization headers.
- Redact names, email addresses, phone numbers, addresses, payment details, and internal identifiers where they are not needed.
- Use representative placeholder values while preserving the original data types and nesting.
- Prefer a local formatter for confidential, regulated, customer-provided, or production-only payloads.
- Do not paste a secret into a tool simply because the response is difficult to read.
- After redaction, verify that the sample still reproduces the structural problem.
If a response contains a JWT, inspect it separately and never treat decoding as proof that a token is valid. The JWT decoder and validator guide covers safer inspection practices.
Common mistakes
- Confusing formatting with validation: indentation improves readability, but it does not confirm that the API returned the intended schema or values.
- Debugging a copied sample instead of the raw response: editors, logs, and chat systems can escape, truncate, or transform content. Preserve the original capture.
- Ignoring the status code: an error response may be valid JSON while still indicating authentication, validation, rate, or server failure.
- Assuming missing and null mean the same thing: serializers and clients may handle an absent field differently from an explicit null.
- Comparing text without comparing structure: whitespace and property order can create noise, while type changes can be missed.
- Sharing secrets in bug reports: redact first, then check the redacted sample for reproducibility.
- Changing several variables at once: keep the request, response, client version, environment, and relevant code path identifiable so the result can be repeated.
For a reusable report, include the endpoint pattern, method, sanitized request body, status code, relevant headers, formatted response, expected shape, actual difference, and the smallest set of steps that reproduces the failure.
When to revisit
Return to this checklist whenever a new endpoint, response version, client integration, or serialization setting is introduced. It is also worth revisiting before seasonal planning cycles or other periods when traffic, data volume, scheduled jobs, or downstream dependencies change. Those changes can expose assumptions about optional fields, pagination, empty results, time zones, and error handling.
Update your team’s JSON debugging workflow when tools, runtimes, API clients, schemas, or logging practices change. Review formatter and validator choices periodically, especially if payloads now include more sensitive data or if the workflow has moved from an individual machine to shared automation. Keep a small set of sanitized fixtures for valid responses, malformed responses, empty results, authentication errors, and unexpected data types.
Before closing the next API bug, use this short final checklist:
- Preserve the raw response and request context.
- Format and validate a sanitized copy.
- Confirm status, content type, and top-level shape.
- Check required fields, types, nullability, and nested values.
- Compare the response with a known-good fixture or documented contract.
- Record the smallest reproducible example and the expected behavior.
That process turns a difficult payload into evidence that another developer can inspect, test, and maintain.