JSON Formatter and Validator

Format, minify and validate JSON — and when it is broken, get told exactly where.

Valid JSON12 keys4 objects1 arrays3 levels deep268 B
Formatted
322 B

How it works

  1. 1Paste JSON on the left. It is validated and formatted as you type — there is no button to press.
  2. 2When it is broken you get the line and column, the offending line, and a caret under the exact character.
  3. 3Choose 2 spaces, 4 spaces, tabs, or minify to strip every byte of whitespace.
  4. 4"Sort keys" orders every object alphabetically, recursively — which is what makes two payloads comparable.

Common questions

Why does it say my JSON is invalid when it looks fine?
The usual culprits are a trailing comma after the last item, single quotes instead of double, unquoted keys, or a comment. All four are legal in JavaScript and none of them are legal in JSON. The caret under the error line shows exactly where the parser stopped.
Can JSON contain comments?
No. The specification has no comment syntax, which trips people up constantly because JavaScript object literals do. If you need comments in configuration, JSON5 or YAML are the usual answers.
What does sorting keys achieve?
JSON objects have no meaningful key order, so two identical payloads can serialise differently. Sorting both makes a line-by-line comparison possible. Array order is left alone, because in an array the order genuinely is the data.
Is a bare number or string valid JSON?
Yes. Since RFC 7159, any JSON value is a valid document — 42, "text", true and null all parse. Older parsers that insist on an object or array at the top level are following the superseded spec.
Is my JSON sent anywhere?
No. Parsing and formatting happen entirely in your browser. That matters given how often the thing being debugged is an API response with real customer data in it.

Comparing two payloads rather than fixing one?

Sort the keys in both, then put them side by side in Document Diff — it highlights the specific values that changed, not just the lines.

Open Document Diff

Related tools