JSON Formatter & Diff
A JSON formatter, validator and diff tool. Paste JSON to validate it and pretty-print it, with clear error messages on invalid input. Paste a second document to see a key-sorted, value-level diff — so real changes stand out instead of formatting or key-order noise. Everything runs in your browser.
{
"name": "api",
"replicas": 2,
"ports": [
80,
443
],
"env": {
"TIER": "prod",
"DEBUG": false
}
}{
"replicas": 3,
"name": "api",
"env": {
"DEBUG": false,
"TIER": "prod"
},
"ports": [
80,
8443
]
}Value diff (keys sorted — only real changes shown)
Two everyday JSON jobs — make it readable, and see what changed — are both easy to get subtly wrong. Formatting is the simple half: parse the document (which also validates it) and re-print it with consistent indentation, so a minified blob or a hand-edited config becomes legible and any syntax error is reported instead of silently breaking something downstream.
Diffing is where a naive tool misleads you. Run a plain text diff over two JSON documents and it screams about every reindentation and every reordered key — none of which changed the data. The fix is to normalize first: parse both sides and re-serialize them with keys sorted and identical formatting, then diff that. Now two objects carrying the same values look identical no matter how they were written, and only genuine changes remain.
The normalization respects what JSON actually means: object keys are unordered, so sorting them removes false differences, while arrays are ordered, so their element order is preserved and a real reshuffle still shows up. That distinction is exactly why a JSON-aware diff beats a text diff for comparing API responses, config versions or fixtures. And because it all runs locally, it is safe to paste JSON that holds secrets or customer data.
How it works
- Validates and pretty-prints JSON with clear error messages.
- Diffs two documents with keys sorted — only real changes show.
- Preserves array order (ordered) while ignoring key order (unordered).
- Runs fully in your browser; nothing is uploaded.
Frequently asked questions
What does formatting do to my JSON?
It parses the JSON to confirm it is valid, then re-serializes it with consistent indentation so it is readable. If the input is invalid, it reports the error (such as an unexpected token or a trailing comma) so you can fix it. Formatting never changes the data — the values, types and structure are identical, just laid out clearly. It is the fastest way to make a minified or hand-edited blob legible.
How is the JSON diff different from a plain text diff?
A plain text diff would flag every reformatting or key-order change as a difference, drowning out the real ones. This tool first normalizes both documents — parsing them and re-serializing with keys sorted and consistent indentation — then diffs the normalized text. The result shows only genuine value and structure changes, because two objects with the same data but different key order come out identical. That is what you usually want when comparing API responses or configs.
Does key order matter in JSON?
By the JSON spec, object key order is not significant — {"a":1,"b":2} and {"b":2,"a":1} represent the same object. Arrays, however, are ordered, so element order does matter. This tool sorts object keys before diffing (so key-order noise disappears) but preserves array order (so a real reordering of a list still shows up). That matches how the data is actually interpreted.
Is my data sent anywhere?
No. Parsing, formatting and diffing all happen in your browser with JavaScript — nothing is uploaded, logged or stored. That makes it safe to format or compare JSON that contains configuration, tokens or other sensitive values. Reload the page and the data is gone.