JSON · 7 min read

How to Use JSON Inspector: A Documentation Guide for API Examples

Broken JSON in your API docs costs reader trust in seconds. Here is a paste-and-check workflow that keeps every example valid before it ships.

Nothing destroys confidence in API documentation faster than an example that does not parse. A developer lands on your page, copies the request body, sends it, and gets a parser error. Within seconds they have concluded that the docs are stale, the API is sloppy, or both — and they go looking for a competitor whose examples actually run. The JSON in your documentation is not decoration; it is the first part of the product most readers ever touch. Keeping every example valid under the strictest JSON rules is cheap insurance, and checking one example takes about ten seconds with a strict inspector.

This guide walks through the full workflow: how to draft an example, how to verify it before publishing, which strict rules matter and why, how to maintain a canonical example set as the API evolves, why error responses deserve the same care as success responses, and how to keep examples small without lying about the shape of your data.

The documentation workflow: draft, paste, fix, format, publish

Treat every documentation example like code that must pass a linter before it merges. The loop has five steps:

  1. Draft the example next to the endpoint description, in whatever editor you are already using.
  2. Paste it into the JSON Inspector before it goes anywhere near the docs page.
  3. Fix everything the inspector flags until the status line is green. A strict parser catches trailing commas, single quotes, unquoted keys, and stray control characters — precisely the mistakes that slip past a casual read.
  4. Format with the inspector's formatter so the published example uses canonical, consistent indentation.
  5. Publish, and keep the validated text as the source of truth. Never hand-edit a published example without re-running the check.

The order matters more than it looks. Formatting last means you validate the exact bytes a reader will copy, not an earlier draft that has since drifted. Formatting first and then "just tweaking one value" is how broken examples are born — the tweak introduces a trailing comma, nobody re-checks, and the page ships with a parser trap in it.

A broken example, dissected

Here is a realistic example assembled from the habits that produce most documentation bugs. It looks fine. It is not:

{
  "user": {
    "id": 4821,
    "email": '[email protected]',  // confirm with backend
    "roles": ["admin", "editor"],
  },
  "created": "2026-08-20T09:15:00Z"
}

Three strict-mode failures hide in nine lines. The email is single-quoted, which JavaScript tolerates but JSON does not. The comment after it is a JavaScript habit that no JSON parser accepts — there is no comment syntax in the spec at all. And the comma after the roles array is a trailing comma, legal in modern JavaScript and arrays-in-progress everywhere, but a hard parse error in JSON. A lenient validator might let some of this slide or auto-repair it silently; a strict inspector reports all three, with the position of each, before the example ever reaches a reader.

Keeping examples valid under strict rules

Once the status line is green, the example is valid JSON — but good documentation examples follow stricter conventions than the spec demands. Three of them matter most.

No comments — use a note member or link out

Writers reach for // comments to explain a field, and readers copy the result straight into a client and hit an error. JSON has no comment syntax, full stop. If the example needs an explanation, put it outside the code block in prose, or inside the payload as a member your API genuinely ignores — a "note" or "comment" string is valid JSON and travels with the example. For the full story on where comments came from and what to do about trailing commas, see comments and trailing commas in JSON.

Realistic numbers and values

Placeholder values teach the wrong types. 1234 suggests an integer where the API returns a decimal; "foo" hides that a field expects an email, a UUID, or an ISO timestamp. Every value in a documented example should be one a real response could contain: real-looking IDs, plausible amounts with the right precision, full timestamps. Realistic examples also double as test fixtures — someone will eventually paste yours into a mock server.

Quote style: double quotes, always

JSON allows exactly one string delimiter: the double quote. Keys and values, no exceptions. Examples written with single quotes or bare keys are code that happens to look like JSON, and readers should never have to find out the hard way. The reasons go back to the spec's grammar — why JSON requires double quotes covers the history and the exact rule.

The fixed, canonical version

Applying the workflow and the rules above turns the broken example into this:

{
  "user": {
    "id": 4821,
    "email": "[email protected]",
    "roles": ["admin", "editor"]
  },
  "created": "2026-08-20T09:15:00Z"
}

The comment moved into the prose around the block ("emails are confirmed asynchronously by the backend"), the quotes are doubled, the trailing comma is gone, and the indentation is what the inspector's formatter produces. Every example on the page should look like this one: same indent width, same key order as the real response, same formatting the formatter emits. Consistency reads as competence.

Maintain a canonical example set

One validated example per endpoint, stored in a single directory beside the docs source, is a canonical example set. Its whole job is to be pasted into the inspector and checked — all of it, after every API change. When a field is renamed or a new member appears, run the entire set through the inspector again. Paste-and-check is a ten-second regression test per example: it catches every doc that now describes an API that no longer exists.

The set pays for itself the first time a schema change lands. Code gets compiled and tested before merge; documentation examples deserve the same gate. A broken example in shipped docs is a bug with a public blast radius, and this workflow makes it impossible to introduce one without noticing.

Document error responses too, not just success

Success examples get all the attention; error bodies get whatever is left. That is backwards. The first time many developers meet your API, it fails — a wrong parameter, an expired token, a rate limit — and the error body is what they read. If the docs never show that shape, they are guessing, and guesses produce bug reports.

Every endpoint description should include at least one error example, ideally in the problem details shape so clients can branch on type instead of parsing prose:

{
  "type": "https://api.example.com/errors/invalid-email",
  "title": "Invalid email address",
  "status": 400,
  "detail": "The value 'not-an-email' is not a valid email.",
  "instance": "/users/4821"
}

Error examples go through the same inspector loop as success examples — same paste, same green status line, same formatter. For how to design and read these bodies member by member, see the guide on reading problem details responses like a contract.

Keep examples small but complete

The worst shortcut in documentation writing is the ellipsis. An example like { "user": { ... }, "items": [ ... ] } is not JSON — it is a sketch of JSON — and every reader who copies it gets a parse error. Omission must be shown by removing members, never by hiding them behind dots, and the prose should say so plainly: "the items array is omitted for brevity; it follows the schema in the next section." A removed member keeps the example valid; an ellipsis makes it a lie about the shape of the data.

Small and complete also means trimming irrelevant branches. If the endpoint's response has fourteen members and the section is about pagination, keep three: the pagination members, one content member for context, and nothing else — then say what you left out. Short examples get read; complete examples get copied; the combination gets trusted.

Docs anti-patternFix
... or "etc" inside a structureRemove members and say what was omitted in prose
// comments inside an exampleMove to prose, or use a member the API ignores, or link out
Single quotes or unquoted keysDouble quotes everywhere, keys included
Placeholder values like 1234 or "foo"Realistic, correctly typed values
Only success responses documentedAt least one error example per endpoint
Examples hand-edited after publishingRe-paste into the inspector after every edit

A note on versioning

Examples are versioned artifacts, whether you treat them that way or not. When your API changes shape, the docs page and the example set must change in the same change — one pull request, one review, one inspector run over every example. If responses differ across API versions, each version needs its own example, labeled with the version it belongs to; sharing one example across versions is how a v2 field quietly appears in v1 docs. And when a breaking change lands, resist the urge to delete old examples silently: a short "changed in v3" note beside the updated example tells existing integrations what moved and why their diff tool is complaining.

The habit, in one line

Draft it, paste it, make the status line green, format it, publish it — and re-run the whole set every time the API moves. Ten seconds of checking per example buys back the trust that a single parse error destroys.

Reproduce every example locally with the JSON Inspector or the matching tool on the workbench. Nothing you paste leaves your browser.