When an API response, configuration file, or test fixture fails, a JSON formatter can make the problem visible—but formatting alone does not prove that the data is valid or usable. This checklist explains how to format JSON online or in an editor, find common syntax errors, distinguish syntax validation from schema validation, and inspect data safely without exposing sensitive values.
Overview
JSON is a text format built from objects, arrays, strings, numbers, booleans, and the null value. Its rules are deliberately small, but one extra comma, mismatched quote, or missing closing bracket can prevent an entire payload from being parsed.
A reliable debugging workflow has three stages:
- Format: Add indentation and line breaks so the structure is easier to read.
- Validate syntax: Check whether the text can be parsed as JSON at all.
- Validate structure: Check whether valid JSON contains the fields, types, and nesting your application expects.
A browser-based JSON formatter or validator is useful for a quick inspection, especially when a response is difficult to read in a terminal or browser developer tools. For credentials, customer data, production payloads, or private tokens, use a local editor or an approved internal tool instead. If you need to inspect authentication data, keep JSON validation separate from token verification; a decoded token can be structurally valid without being trusted. See the JWT debugging guide for that distinction.
JSON syntax reference
| Element | Valid form | Common error |
|---|---|---|
| Object | {"name":"Ada"} | Using an unquoted key |
| Array | ["red","blue"] | Leaving a trailing comma |
| String | "status" | Using smart or single quotes |
| Number | 42 or 3.14 | Adding a language-specific suffix |
| Boolean | true or false | Writing True or False |
| Empty value | null | Writing undefined |
Checklist by scenario
When you need to format JSON online
- Copy only the JSON value, not a log prefix such as
Response:, an HTTP status line, or a JavaScript variable declaration. - Paste it into a trusted formatter or validator.
- Use a readable indentation setting, then scan the resulting object and array boundaries.
- Compare the first and last characters. A top-level object normally begins with
{and ends with}; a top-level array begins with[and ends with]. - Do not assume successful formatting means the application will accept the payload. Formatting may only make already-valid JSON easier to inspect.
When the validator reports invalid JSON
Start at the reported line and column, then inspect the preceding token as well. Parsers often detect a problem at the point where the structure becomes impossible, while the actual mistake is one character earlier.
- Trailing comma: Remove the comma before a closing brace or bracket.
- Incorrect quotes: Replace single quotes and typographic “smart quotes” with straight double quotes.
- Unquoted keys: Change
{name: "Ada"}to{"name": "Ada"}. - Missing delimiter: Add a comma between properties or array items, but not after the final item.
- Missing closing character: Count nested
{}and[]pairs, preferably with editor bracket matching. - Unsupported values: Replace JavaScript-only values such as
undefined,NaN, comments, or functions with JSON-compatible values.
For example, this JavaScript-like object is not valid JSON:
{
userId: 'u-104',
active: True,
roles: ['admin',],
}A valid JSON version is:
{
"userId": "u-104",
"active": true,
"roles": ["admin"]
}When the JSON parses but the application still fails
Move from syntax validation to contract validation. Check whether required fields exist, whether names use the expected casing, and whether each value has the expected type. A field containing "42" is a string, while 42 is a number. Similarly, an empty array is not the same as a missing field, and null may have different application semantics from either.
If the project uses JSON Schema, validate the payload against the schema used by the API or test suite. Review required properties, allowed values, minimum and maximum constraints, formats, and nested item definitions. Keep the schema version or revision alongside the fixture when practical so a future change does not make an old example ambiguous.
What to double-check
Formatter versus validator
A formatter focuses on presentation. A syntax validator answers whether a parser can read the text. A schema validator answers whether the parsed value matches a defined contract. These tools overlap, but they are not interchangeable.
| Need | Best check | Question it answers |
|---|---|---|
| Readable output | JSON formatter | Can I see the nesting and values clearly? |
| Parseability | JSON validator or parser | Is this legal JSON? |
| API contract | JSON Schema or application tests | Does this valid JSON have the right shape and types? |
| Business behavior | Integration or domain tests | Does the application handle these values correctly? |
Privacy and redaction
Before using an online code tool, remove or replace secrets and personal data. Redact access tokens, cookies, API keys, passwords, private URLs, email addresses, customer identifiers, payment details, and unneeded request headers. Preserve the value type and approximate shape where possible: replace a secret with "REDACTED" rather than deleting the whole property if the field is relevant to the test.
Also check copied payloads for nested secrets. Authorization data may be buried in headers, metadata, webhook objects, or error details. If a real credential has been exposed, follow your organization’s incident and rotation process rather than treating redaction as a repair.
Editor and command-line checks
For repeatable work, prefer project tooling over a one-off browser paste. Most code editors can format a selected JSON document and highlight unmatched brackets. A local parser can be added to a test or pre-commit workflow so invalid fixtures fail close to the change that introduced them. Use the formatter configured by the repository when whitespace, key ordering, or newline rules matter.
When debugging a failed build or deployment, preserve the original payload and record the transformed version separately. This makes it easier to determine whether the error came from the source response, a template, an environment variable, or a build step. For broader CI troubleshooting, see the GitHub Actions debugging guide.
Common mistakes
- Confusing JavaScript with JSON: JSON resembles object literals but does not allow comments, bare keys, single-quoted strings, or JavaScript expressions.
- Fixing only the reported character: A missing comma or quote can cause several misleading errors. Recheck the surrounding object after every correction.
- Changing data while formatting: A formatter should not be used to silently rename fields, convert types, or remove unknown properties.
- Assuming valid means correct: A parser can accept an empty object even when the endpoint requires several fields.
- Ignoring encoding: Unexpected characters may result from copying text through a system that changes quotation marks or line endings. Re-enter the affected string or inspect the raw response.
- Testing only the happy path: Include fixtures for missing fields, empty arrays, null values, unexpected types, and extra properties when the API must handle them.
- Sharing live data with an unapproved tool: Convenience is not a reason to paste production secrets or personal information into a third-party form.
When to revisit
Return to this checklist whenever you inspect a new API response, update a configuration file, add a fixture, or encounter a parser error. Revisit the workflow before a release if the API contract, JSON Schema, serializer, runtime, or formatting rules have changed. It is also worth checking after a tool migration, editor change, or CI update, because a different formatter or parser may expose assumptions that were previously hidden.
For a practical final pass:
- Keep an untouched copy of the input.
- Redact sensitive values before using any browser-based developer tool.
- Format the data to expose its structure.
- Validate syntax, then validate the schema or application contract.
- Inspect types, required fields, nesting, and null handling.
- Run the relevant local or CI tests.
- Save a minimal, reusable fixture that reproduces the problem without private data.
This sequence turns a one-time “format JSON online” task into a repeatable debugging habit. It also keeps syntax errors, contract mismatches, and application behavior separate—making each problem easier to diagnose and safer to fix.