JSON Diff
Paste JSON in both panels and click Compare.
A JSON diff tool compares two JSON documents structurally — parsing both inputs and reporting every key that was added, removed, changed, or left unchanged, identified by its full dot-notation path. Unlike plain text diff, it ignores whitespace and key ordering so only real data differences are flagged.
JSON Diff — Compare Two JSON Objects
How it works
Last updated: November 2026JSON Diff parses both JSON inputs structurally and compares them key-by-key — independent of formatting or key ordering. Paste JSON A (original) and JSON B (modified) into the panels, then click Compare to see every difference with its full dot-notation path.
- Added — key exists in B but not in A
- Removed — key exists in A but not in B
- Changed — key exists in both but value differs
- Unchanged — identical in both
Nested differences are reported with their full path (e.g. user.address.city). Array elements use bracket notation: [1].name. All processing runs in your browser — neither JSON payload is sent to any server.
Diff Output Reference
| Status | Meaning | Example path |
|---|---|---|
| + ADDED | Key present in B, absent in A | user.city |
| − REMOVED | Key present in A, absent in B | user.phone |
| ~ CHANGED | Same key, different primitive value | user.age |
| ⇄ TYPE | Same key, type changed (e.g. string → number) | config.timeout |
| = SAME | Identical in both A and B | user.name |
Tips & Tricks
Key order doesn't matter
Unlike text diff, JSON diff parses both inputs first. Two objects with the same keys in different order are reported as identical. Only actual value differences are flagged.
Arrays are compared by index
Array elements are matched by their position ([0], [1], ...). Inserting an element at the beginning shifts all subsequent elements, making every following element appear changed. If order doesn't matter, sort arrays before diffing.
Watch for type-changed keys
A common API regression is a field changing from a string "123" to a number 123. These are reported as TYPE changes — not value changes — so filter for type changes first when auditing an API for breaking changes.
Format JSON before diffing complex objects
If you paste minified JSON, the diff still works correctly — but formatting it first with the JSON Formatter makes the input panels easier to read. The diff itself is format-agnostic.
null ≠ missing key
A key with value null is not the same as a missing key. {"a": null} vs {} will show a as REMOVED — not unchanged. Many APIs use null to signal "present but empty" and omit the key entirely to signal "absent".
Use Swap to check the reverse diff
Swapping A and B reverses the perspective: what was "added" becomes "removed" and vice versa. Use this when you want to view the diff from the other direction — for example, "what would need to change to roll back from B to A?"
Code Examples
Node.js (deep-diff)
const { diff } = require('deep-diff'); // npm install deep-diff
const a = { user: { name: 'Alice', age: 30 } };
const b = { user: { name: 'Alice', age: 31, city: 'NYC' } };
const changes = diff(a, b);
// [
// { kind: 'E', path: ['user', 'age'], lhs: 30, rhs: 31 },
// { kind: 'N', path: ['user', 'city'], rhs: 'NYC' }
// ]
// kind: N=added, D=deleted, E=edited, A=array change Python (deepdiff)
from deepdiff import DeepDiff # pip install deepdiff
a = {"user": {"name": "Alice", "age": 30}}
b = {"user": {"name": "Alice", "age": 31, "city": "NYC"}}
diff = DeepDiff(a, b)
print(diff)
# {
# 'values_changed': {"root['user']['age']": {'new_value': 31, 'old_value': 30}},
# 'dictionary_item_added': ["root['user']['city']"]
# } CLI (jq + diff)
# jq — extract and compare specific fields
jq '.user.age' a.json
jq '.user.age' b.json
# diff two formatted JSON files (text diff, order-sensitive)
diff <(jq . a.json) <(jq . b.json)
# Python one-liner deep diff
python3 -c "
import json, sys
from deepdiff import DeepDiff
a = json.load(open('a.json'))
b = json.load(open('b.json'))
print(DeepDiff(a, b).pretty())
" Frequently Asked Questions
- What is a JSON diff?
- A JSON diff compares two JSON documents structurally and reports which keys were added, removed, modified, or unchanged — using dot-notation paths like
user.address.cityso you can pinpoint exactly where the difference is. Unlike a plain text diff, a JSON-aware diff parses both inputs first so it ignores whitespace, indentation, and key ordering — two objects with identical data but different formatting show as identical. The tool is especially useful when comparing API responses between environments, reviewing configuration changes, or auditing what changed between two versions of a JSON schema. Nested objects are traversed recursively, meaning you get the full path to every changed leaf value rather than a vague "object changed" message. Libraries like deep-diff (Node.js) and deepdiff (Python) implement the same structural comparison programmatically. - Why not use a plain text diff for JSON?
- A plain text diff is order-sensitive and format-sensitive. Two semantically identical JSON objects formatted differently will show as completely different. A JSON-aware diff parses both inputs first and compares their values structurally — independent of key ordering or whitespace. For example,
{"b":2,"a":1}and{"a":1,"b":2}are reported as identical by a JSON diff but would show two changed lines in a text diff. This distinction is critical when comparing API responses, where servers may return JSON keys in different orders across calls or environments. If you are comparing minified JSON alongside pretty-printed JSON, a text diff becomes entirely unreadable, whereas a JSON diff handles both representations correctly. - How are nested differences reported?
- Nested differences use dot-notation:
user.address.city. Array elements use bracket notation:[1].name. This lets you locate any change in a deeply nested document without reading through the entire structure. For example, in a large Kubernetes manifest or Terraform plan output, a change buried five levels deep surfaces as something likespec.template.spec.containers[0].image— immediately pointing you to the exact field without having to scroll through hundreds of lines. The deepdiff Python library reports the same information using Python's bracket accessor notation:root['spec']['template']['spec']['containers'][0]['image']. Both notations unambiguously identify the location of the change in the document tree. - How are array differences handled?
- Arrays are compared by index. Element [0] in A is compared against [0] in B, [1] against [1], etc. If B has more elements they are reported as added; if A has more they are removed. Inserting at the start of an array will show every subsequent element as changed. This index-based approach is straightforward but has an important caveat: if you have an array of user objects ordered by creation date and a new user is inserted at position 0, every existing user will appear as "changed" in the diff even though their data is unmodified. For arrays where identity matters, pre-sort both arrays by a stable key (such as
id) before comparing, or switch to a library that supports key-based array matching such as deepdiff withignore_order=True. - What is a type change in a JSON diff?
- A type change occurs when a key exists in both A and B but its type changed — e.g. from string to number, or from object to array. Type changes are reported separately because they often indicate a schema-level breaking change. A common real-world example is an API field that was originally typed as a string
"timeout": "30"and was later changed to a number"timeout": 30— these are semantically similar but will break any client that calls.split()or similar string methods on the value. Another frequent case is a field changing fromnullto an object as a feature is turned on. Filtering for type-changed entries first during an API version audit helps triage breaking changes from cosmetic value changes quickly. - How do I compare JSON in JavaScript?
- For equality:
JSON.stringify(a) === JSON.stringify(b)(order-sensitive). For a structural diff, use thedeep-diffnpm package:diff(objectA, objectB)returns an array of change objects with kind (N=added, D=deleted, E=edited, A=array). Install it withnpm install deep-diff, thenconst { diff } = require('deep-diff'); const changes = diff(a, b);. Each change object includes apatharray (e.g.['user', 'age']),lhs(left-hand/original value) andrhs(right-hand/new value). For order-independent object comparison without a library, sort both objects' keys beforeJSON.stringify:JSON.stringify(a, Object.keys(a).sort()). - How do I compare JSON in Python?
- For equality:
json_a == json_bafter parsing. For a structural diff:pip install deepdiff, thenDeepDiff(a, b)which groups results intodictionary_item_added,dictionary_item_removed,values_changed, andtype_changes. For human-readable output, callDeepDiff(a, b).pretty(). To ignore array ordering, passignore_order=True. DeepDiff also supportsexclude_pathsto skip noisy fields like timestamps:DeepDiff(a, b, exclude_paths=["root['updated_at']"]). The library handles arbitrarily nested dicts, lists, and mixed types — making it the standard Python tool for API response regression testing in CI pipelines. - Can I use JSON diff to find API response changes?
- Yes — paste the two API responses into the panels to see exactly which fields changed, were added, or were removed. This is faster and more precise than manually scanning through large payloads, and is useful for comparing staging vs production, or V1 vs V2 responses. A practical workflow is to capture the response with
curl -s https://api.example.com/v1/users/1 | jq . > v1.jsonandcurl -s https://api.example.com/v2/users/1 | jq . > v2.json, then paste both into this tool. The diff will immediately surface any renamed fields, removed keys, or type changes — all of which could constitute breaking changes for API consumers. This technique is also useful before and after a database migration to verify the shape of serialised records has not unexpectedly changed. - What does the path "(root)" mean?
- The path "(root)" means the difference is at the top level — the two inputs are incompatible root types (e.g. one is an object and the other is an array), or both are primitives with different values. This most commonly happens when an API endpoint that previously returned a JSON object
{"users": [...]}is changed to return a JSON array[...]directly — a breaking change that every client must handle. It also appears when comparing two bare primitives, such as"hello"vs"world". Valid JSON can have any value at the root — object, array, string, number, boolean, or null — so "(root)" simply indicates the structural incompatibility starts at the outermost level rather than inside a nested property. - Is my data sent to a server?
- No. All comparison runs entirely in your browser using JavaScript. Neither JSON A nor JSON B is sent to any server, and no account is required. This makes the tool safe to use with confidential API responses, internal configuration files, authentication tokens, or any data that should not leave your machine. The diff logic is implemented as a pure TypeScript module with no external network calls — you can verify this by opening your browser's network inspector while using the tool and observing zero outbound requests triggered by the comparison. The same browser-based approach means the tool works fully offline once the page has loaded.
Related Tools
Other free developer tools available on DevFormatter.
JSON Formatter
Format, validate, and minify JSON. Sort keys, find duplicates, and explore with Tree view.
jq Playground
Run jq queries against JSON to filter, transform, and extract data in your browser.
JSONPath Playground
Query JSON with JSONPath expressions like $.store.books[*].title instantly in your browser.
JSON to YAML
Convert JSON to clean, readable YAML instantly in your browser.
Text Diff
Compare any two text blocks line-by-line. Myers diff, colour-coded insertions and deletions.