JSON Formatter & Validator

JSON Formatter & Validator
Format, minify and inspect JSON. Everything runs in your browser.
Sort keys

Input
Output

Format, validate and inspect JSON. When a payload will not parse, the error points at the exact line and column instead of just saying "unexpected token".

A JSON error message points at a byte offset, which is not much help in a 4,000-line payload. Formatting the document is how you find the problem: once it is indented, a missing comma or an unclosed bracket becomes a visible break in the structure rather than a number.

Parsing here uses the browser’s own JSON parser, so what the page accepts is exactly what your code will accept — including the things people expect to work and which the specification does not allow: trailing commas, single-quoted strings, comments and unquoted keys are all errors, and it is better to learn that here. Minifying strips whitespace only; key order and values are untouched.

Formatting is only half of what this page is for; the other half is finding out what a document actually contains. The statistics row counts objects, arrays, keys and maximum nesting depth, which is the fastest way to get the shape of an unfamiliar API response before writing anything against it. Depth in particular is worth a look: a payload nested eight levels deep is a payload whose access expressions will be long and fragile, and it is usually a sign that the response was assembled from several joins rather than designed.

Sorting keys changes nothing about a document and a great deal about comparing two of them. JSON objects have no defined key order, so two responses that are semantically identical can serialise their fields differently — different server versions, different serialisation libraries, or simply a different insertion order. Diffing them raw produces a wall of noise. Sorting both first reduces it to the fields that genuinely differ, which is why the switch is here rather than in a separate tool.

Escape and unescape handle the shape that turns up in logs and webhook payloads: a JSON document that has been serialised into a string and then embedded inside another JSON document, with every quote backslashed. Reading one of those by eye is miserable and editing one by hand reliably breaks it. Unescaping first, formatting, then escaping the result back is the round trip that keeps the quoting correct, and it is worth doing in that order rather than trying to fix the escaped form in place.

Two silent losses are worth watching for in any JSON round trip. Duplicate keys are legal to write and the specification does not say what a parser should do with them; every mainstream implementation keeps the last one and discards the earlier silently, so a payload that carries the same field twice loses data without an error anywhere. Large integers are the other: JavaScript parses every JSON number into a double, which is exact only up to 2^53, so a 19-digit identifier arrives subtly changed and formatting it here shows the changed value rather than the original. If a numeric id ever fails to match, this is the first thing to check.

How to use JSON Formatter & Validator

  1. Paste JSON into the input pane, or press Paste to pull it from your clipboard.
  2. Press Format to indent it, or Minify to strip whitespace for transport.
  3. If it fails to parse, read the error under the input — it names the line and column.
  4. Copy or download the result from the output pane.

Tips & gotchas

  • The statistics row counts objects, arrays, keys and nesting depth, which is a quick way to sanity-check an unfamiliar API response.
  • Turn on "Sort keys" to make two responses comparable before diffing them.
  • Escape and Unescape handle JSON that has been embedded inside a JSON string — a common shape in logs and webhook payloads.

Frequently asked questions

Is my data sent anywhere?

No. Parsing and formatting run entirely in your browser.

How large a document can it handle?

It is limited only by your browser’s memory. Multi-megabyte documents work, though very large ones will feel sluggish in a textarea.

Does it support JSON5, comments or trailing commas?

No — it uses the browser’s strict JSON parser, so a comment or trailing comma is reported as an error. That is usually what you want when validating a payload.