Guide
How to format and validate JSON
Learn what valid JSON actually requires, the errors that break parsers, and how to pretty-print data without changing its meaning.
Updated 2026-08-17
Why JSON looks “fine” and still fails
JSON is a data format, not a sketch of an object. A parser does not guess. If a key is missing quotes, a trailing comma remains after the last property, or a string uses single quotes, the document is invalid. People see that every day when an API returns 400 and the payload “looks alright” in a chat window.
Formatting and validation are two different jobs that usually happen together. Validation answers: can a standards-following parser read this? Formatting answers: can a human read it? Pretty-print adds spaces and line breaks. It should not rename keys, drop nulls, or reorder semantics you rely on — only whitespace.
Rules that actually matter
Object keys must be double-quoted strings. Booleans are lowercase true and false. Null is null, not None or undefined. Numbers are not quoted unless you intend them to be strings. Arrays are ordered lists; objects are unordered maps. Duplicate keys are allowed by some parsers and ignored by others — treat them as a bug in your source, not as a feature.
Comments are not part of the JSON spec. Tools that accept // or /* */ are reading JSONC or JSON5. If you are posting to a typical REST API, strip comments first. The same applies to trailing commas, which JavaScript object literals allow but JSON does not.
How to check a payload quickly
Paste the text into a JSON formatter that reports the first parse error with a line hint. Fix that error before chasing later ones; one missing brace cascades. Indent with two or four spaces depending on the repo you will commit to. After it parses, scan for the data you expected: the right types, no accidental stringified numbers, arrays where lists belong.
If you are comparing two payloads, format both first. Diffing minified JSON is how people miss a single-character change. If you need to send the document on the wire, minify only after you trust the structure — minifying is the reverse of pretty-print and should still round-trip.
What a browser tool will not do
A client-side formatter is not a schema validator. It will not tell you that customerId should be a UUID, or that a field is required by your OpenAPI spec. For that you need a schema (JSON Schema, protobuf, etc.). The browser tool is the first gate: is this even JSON?
Because this site formats in your browser, the payload is not uploaded to run the widget. That is useful for configs that contain tokens. It is not a substitute for rotating a secret you already pasted into a chat log.
Related tool: JSON Formatter