How to compare JSON online
- Add both documents. Paste the original on the left and the changed version on the right, or use Open file on each side. You can also paste both into the left box with a line containing only
---between them, and they will be split for you. - Choose how arrays compare. Keep compare by index for ordered lists. Choose ignore order for tags and roles, or match objects by key when an array holds records with an
id. - Read the result. Each difference appears once, with its path. Switch to Highlighted documents to see the changes in context, or to JSON Patch for a machine-readable version.
Semantic JSON diff vs. text diff
A line-based diff (git diff, an editor's compare view) works on raw text. It flags anything that moved on the page: a reordered key, different indentation, a trailing comma added or removed after a reformat. Most of those “changes” are noise, because the parsed data is the same.
This tool parses both sides first and then walks the two trees together, comparing by path. The result is a short list of real differences, such as $.address.city changed from "Berlin" to "Munich", $.active added, or $.roles[2] removed. Numbers are compared by value, so 1, 1.0 and 1e0 are equal. Large integers are compared digit by digit, so two 64-bit IDs that differ only in the last digit are not reported as equal. That is a mistake tools built on JSON.parse make.
Why key order does not matter
RFC 8259 defines a JSON object as an unordered collection of name/value pairs, so {"a":1,"b":2} and {"b":2,"a":1} are the same object. Serializers emit keys in insertion order, alphabetical order or hash order, and a round trip through most languages does not keep the original order. So members are matched by name. If you clear Ignore key order, the tool also adds an informational note when the shared keys appear in a different sequence, which is useful when a file must stay byte-stable.
Comparing arrays: by index, by value or by id
Arrays are ordered in JSON, but they are used for different kinds of data, and each needs a different comparison:
| Setting | Use it for | How items are paired |
|---|---|---|
| Compare by index | Ordered lists: pipeline steps, coordinates, table rows | [0] with [0]. A reorder counts as a change. |
| Ignore order | Sets: tags, roles, feature flags, permissions | Equal items are matched wherever they are. Only true additions and removals are reported. |
| Match objects by key | Records: users, products, orders, anything with an id, sku or uuid | Items with the same key value are compared field by field. Paths look like $.users[id=7].email. |
Why this matters: insert one element at the front of a 100-item array, and an index-based diff reports 100 changes and 1 addition, because every item moved down one slot. Matching by key reports exactly one added record. If some items lack the key, the tool falls back to index comparison for that array and says so.
Reading the result
| Label | Meaning | Example |
|---|---|---|
| added | The path exists only on the right | $.sso → true |
| removed | The path exists only on the left | $.trial_ends was null |
| changed | Both sides have the path with different values | $.plan: "pro" → "enterprise" |
| changed + type | The value's JSON type changed, which often breaks clients | $.seats: "5" → 5 (string → number) |
Paths use JSONPath: $ is the root, .key is an object member, [n] is a zero-based array index, and ['odd key'] is used for keys with spaces or symbols. Find any path quickly in the JSON viewer, which copies paths in the same notation.
Export the difference as a JSON Patch
The JSON Patch view writes the difference as an RFC 6902 patch, a list of operations that turn the left document into the right one. HTTP PATCH APIs, Kubernetes (kubectl patch --type=json) and libraries such as fast-json-patch (JavaScript), jsonpatch (Python) and zjsonpatch (Java) all accept this format:
[
{ "op": "replace", "path": "/plan", "value": "enterprise" },
{ "op": "replace", "path": "/seats", "value": 25 },
{ "op": "remove", "path": "/trial_ends" },
{ "op": "add", "path": "/sso", "value": true }
]
Patch paths are positions, so the export is available when arrays are compared by index. Array removals are written from the highest index down, so the patch applies cleanly in order.
Compare JSON in code
JavaScript / Node.js
import { isDeepStrictEqual } from 'node:util';
isDeepStrictEqual(JSON.parse(a), JSON.parse(b)); // true/false, key order ignored
// list the differences
import { diff } from 'jest-diff'; // or: npm i deep-object-diff
Python
import json
a, b = json.load(open("a.json")), json.load(open("b.json"))
print(a == b) # dict comparison ignores key order
from deepdiff import DeepDiff # pip install deepdiff
print(DeepDiff(a, b, ignore_order=True))
jq + diff (command line)
diff <(jq -S . a.json) <(jq -S . b.json) # sort keys, then line diff
jq -n --slurpfile a a.json --slurpfile b b.json '$a == $b' # equality check
Java (Jackson)
ObjectMapper m = new ObjectMapper();
boolean same = m.readTree(a).equals(m.readTree(b)); // ObjectNode equality ignores key order
When a JSON compare helps
- API response regression. Save a known-good response, then diff a fresh one after a deploy to see exactly which fields changed.
- Config drift. Compare staging and production settings, or a file before and after a manual edit.
- Snapshot tests. When a stored snapshot no longer matches, a structural diff shows whether the change is intentional.
- Data migrations. Compare a record before and after an ETL step to confirm that only the intended fields changed.
- Reviewing generated files. Lockfiles, manifests and exported settings are noisy in a text diff. A semantic diff shows only the real changes.
Frequently asked questions
How do I compare two JSON objects online?
Paste the first JSON object on the left and the second on the right (or open two files) and the comparison runs as you type. Differences are listed by JSONPath as added, removed or changed, and you can switch to highlighted documents or a JSON Patch.
Does key order matter when comparing JSON?
No. JSON objects are unordered, so members are matched by name and a reordered key is not reported as a difference. Clear Ignore key order if you also want a note when the order differs.
How are JSON arrays compared?
By index by default, which suits ordered lists. Choose ignore order to match equal items wherever they appear, which suits tags and roles, or match objects by key to pair records by a field such as id so that an inserted record is not reported as many changes.
Can I compare two JSON files?
Yes. Click Open file above each box to load a .json file on each side. The files are read locally in your browser and never uploaded. You can also paste both documents into the left box separated by a line containing only ---.
Does it detect when a value changes type?
Yes. A change such as "5" (string) to 5 (number), or an object replaced by an array, is reported as changed with the old and new type shown. Numbers are compared by value, so 1 and 1.0 count as equal.
What does treat missing as null do?
Normally a key that is absent on one side and null on the other is reported as added or removed. With this option they are treated as equal, which helps when one API omits null fields and another includes them.
Is my JSON uploaded when I compare it?
No. Both documents are parsed and compared by JavaScript in your browser. Nothing is sent to a server, so you can compare production data and private configs safely.