When an API request fails, the visible error is often only the final symptom. This guide gives you a repeatable way to format JSON online, locate syntax errors, validate data against a JSON Schema, compare payload versions, and decide when a browser-based tool is appropriate versus a local command-line workflow.
Overview
JSON is deliberately simple: objects use curly braces, arrays use square brackets, property names and string values use double quotes, and items are separated with commas. Its simplicity makes JSON portable, but a single missing quote or trailing comma can prevent an entire request body from being parsed.
A JSON formatter and a JSON validator solve related but different problems. A formatter, sometimes called a pretty printer, changes whitespace and indentation so that nested data is easier to read. A syntax checker confirms whether the text is valid JSON. A JSON Schema validator goes further by checking whether valid JSON has the expected structure, data types, required properties, and allowed values. A diff tool helps you identify what changed between two payloads.
For sensitive material, prefer a local tool or an approved internal environment. Never paste production credentials, access tokens, personal information, private customer data, or unredacted logs into an unfamiliar online service. Browser-based developer utilities are convenient, but convenience should not override data-handling requirements.
| Tool type | What it checks | Best use |
|---|---|---|
| JSON formatter | Indentation and readability | Inspecting nested API responses |
| JSON syntax checker | Parsing errors and invalid JSON grammar | Finding missing quotes, commas, or brackets |
| JSON Schema validator | Types, required fields, formats, and structure | Checking request and response contracts |
| JSON diff tool | Differences between two JSON documents | Reviewing payload or configuration changes |
| Command-line parser | Local parsing and automation | CI checks and sensitive data |
Checklist by scenario
When the JSON will not parse
- Make a copy of the original input so that you can compare changes.
- Paste the copy into a trusted JSON formatter or syntax checker, after removing secrets and unnecessary personal data.
- Read the reported line and column, then inspect the characters immediately before it. Parsers often report where they became unable to continue, not where the original mistake was made.
- Check matching pairs of
{}and[], commas between properties, and double quotes around every property name. - Run the validator again after each small correction instead of rewriting the entire document at once.
For example, this object is invalid because the property name is not enclosed in double quotes and the final property has a trailing comma:
{
user: "sam",
"active": true,
}
A valid version is:
{
"user": "sam",
"active": true
}
When nested objects or arrays are hard to inspect
Format the document before debugging its meaning. Collapse or expand one level at a time, and check that each closing bracket belongs to the intended opening bracket. Arrays may contain objects, objects may contain arrays, and both can be nested several levels deep. A formatter makes this hierarchy visible; it does not decide whether the hierarchy is correct for your application.
Also distinguish JSON from JavaScript object syntax. JSON does not support comments, single-quoted strings, unquoted property names, functions, or expressions. A file that looks acceptable inside JavaScript may still fail when sent as an application/json request body.
When escaped characters appear in the data
Escaping is a frequent source of confusion. A JSON string may contain escaped quotation marks such as ', a newline represented by \n, or a backslash represented by \\. If JSON is embedded inside another string, such as a command, log entry, or programming-language literal, it may be escaped more than once.
First determine how many layers you are looking at. A response displayed by a debugging console may show a serialized JSON string rather than the parsed object. Decode only the layer you understand, and avoid repeatedly running an online decoder on confidential content. After parsing, verify the actual value rather than judging it from the display format.
When the JSON parses but the API rejects it
Move from syntax validation to contract validation. Compare the payload with the API documentation or its published schema and check:
- Required properties and exact spelling, including capitalization.
- Data types, such as a number versus a numeric string.
- Allowed enum values and case-sensitive status names.
- Array item structure and whether an empty array is permitted.
- Date, email, URI, or other declared formats.
- Whether unknown properties are ignored, rejected, or preserved.
- Content type, character encoding, and the request method.
Use a JSON Schema validator when a schema is available. Confirm which schema dialect and validation settings the tool expects; a validator may support a particular JSON Schema draft or interpret format checks differently. Passing a schema check does not guarantee authorization, business-rule, or database validation will pass.
When two payloads need to be compared
Format both documents consistently before comparing them. A text diff can show many whitespace changes that are not meaningful, while a structure-aware JSON diff can highlight added, removed, or changed properties. Check whether array order is significant for the API before treating reordered items as a meaningful change. For a release or deployment, save the corrected payload and the validation result with the relevant change record rather than relying on a screenshot.
What to double-check
- Request body versus response body: A response may include read-only fields that must not be sent back in an update request.
- Null versus missing:
nullis a value. Omitting a property is different and may trigger different server behavior. - Numbers: Confirm whether an identifier should be a string, especially when leading zeroes matter.
- Booleans: Use
trueandfalse, not quoted strings such as"true", unless the contract explicitly requires strings. - Unicode and line endings: Check that copied text has not introduced invisible characters or altered quotation marks.
- Headers: Valid JSON can still fail if the request sends the wrong content type or is placed in the wrong part of the request.
- Secrets: Redact authorization headers, API keys, cookies, tokens, and credentials before sharing an example or error log. See how to redact API keys and secrets from logs.
For automated workflows, add local parsing and schema validation to tests or continuous integration. A small command-line check can prevent malformed configuration from reaching a deployment. Keep online tools for low-risk, disposable examples or for situations where your organization has explicitly approved them.
Common mistakes
Confusing formatting with validation
Pretty indentation makes a document easier to read, but it does not prove that the values are correct. Always perform a syntax check, then a schema or application-level check when the contract is available.
Fixing the reported line only
A missing quote several lines earlier can cause an error at a later comma or closing bracket. Start at the reported location, then scan backward through the nearest string, object, and array boundaries.
Using JavaScript values in JSON
undefined, NaN, comments, and functions are not JSON values. Convert them deliberately or remove them before serialization. If a value cannot be represented in JSON, document how the receiving API expects it.
Assuming a schema covers every rule
Schema validation can check declared structure, but it may not know whether a username is available, a file exists, or a caller has permission. Treat validation as one stage in a broader API test.
Sharing raw debugging data
Payloads frequently contain more information than expected. Redact before using an online JSON formatter, posting an issue, or sending a HAR file. If the debugging package contains uploaded artifacts, review the transfer and sharing workflow as well; the HAR file safety guide provides a practical checklist.
When to revisit
Return to this checklist whenever an API contract changes, a configuration file is edited, a parser error appears after a dependency update, or a request works in one environment but fails in another. Revisit it before deployment and after adding new required fields, changing data types, or introducing nested objects.
Review your tool choice when your workflow changes. A browser-based JSON formatter may be suitable for a small redacted sample; local validation is the safer default for production payloads, credentials, customer data, and repeatable automation. If your team adopts a new schema dialect, API testing platform, or CI pipeline, confirm that its parser and validator settings match the contract you intend to enforce.
Before closing an incident, use this final action list:
- Preserve the original failing payload securely.
- Redact a separate copy for sharing or online inspection.
- Format and syntax-check the copy.
- Validate it against the applicable schema and API contract.
- Compare it with a known-good request.
- Retest with the correct headers and environment.
- Record the cause and the preventive test, formatter rule, or schema change.
This sequence separates malformed JSON from incorrect data and from transport or application errors. That distinction makes the next failed payload faster to diagnose and easier to fix safely.