SyntaxDock guide
JSON Diff Examples: Structural Comparison Explained
Learn structural JSON comparison through verified examples of property changes, array indexes, JSON Pointer paths, null values, and browser-local limits.
Read a structural comparison
When an API response or JSON configuration changes, a text comparison can highlight formatting alongside meaningful changes. A structural comparison first parses both documents, then compares their values. These examples show how to interpret the result from JSON Diff.
For each example, enter the earlier document under Original JSON, the newer document under Modified JSON, and select Compare JSON. Read the paths and values together: a difference describes the modified document relative to the original.
Find added, removed and changed properties
Here a user gains an active flag, changes name and loses a role. The output is an array of difference entries:
Original JSON
{"name":"Ada","role":"admin"}
Modified JSON
{"name":"Lin","active":true}
Differences
[
{
"type": "added",
"path": "/active",
"after": true
},
{
"type": "changed",
"path": "/name",
"before": "Ada",
"after": "Lin"
},
{
"type": "removed",
"path": "/role",
"before": "admin"
}
]
An added entry has an after value; a removed entry has a before value. A changed entry contains both. This comparison succeeds with Changes: 3, Added: 1, Removed: 1 and Changed: 1. Finding a difference is a successful comparison, not a validation error.
The entries follow deterministic traversal order: object keys are visited in lexical code-unit order and nested values are visited before the next sibling. The list is not grouped by change type or by where keys appeared in the source.
Count whole added and removed subtrees once
An entirely new or missing property is one difference, even when its value contains an object or array. Existing objects are compared inside their shared structure:
Original JSON
{"kept":{"name":"Ada"},"removed":{"nested":[1,2]}}
Modified JSON
{"kept":{"name":"Lin"},"added":{"nested":[3,4]}}
Differences
[
{
"type": "added",
"path": "/added",
"after": {
"nested": [
3,
4
]
}
},
{
"type": "changed",
"path": "/kept/name",
"before": "Ada",
"after": "Lin"
},
{
"type": "removed",
"path": "/removed",
"before": {
"nested": [
1,
2
]
}
}
]
There are three differences here. The new and removed subtrees are preserved as values, while the shared kept object produces a change at its nested name. Counting every scalar inside a new subtree would give a different answer.
Recognize equality despite formatting and key order
These documents contain the same object members. Their spacing and member order differ, but their parsed values agree:
Original JSON
{ "name": "SyntaxDock", "enabled": true }
Modified JSON
{"enabled":true,"name":"SyntaxDock"}
Differences
[]
The summary is No differences found, with all four change counts at zero. The empty result [] means the parsed documents compare equally; it does not mean the input text was identical. Equivalent number spellings and decoded string escapes also compare equally:
Number spelling does not introduce a change. Original: 1. Modified: 1.0. Differences: [].
Negative zero and zero compare equally. Original: -0. Modified: 0. Differences: [].
A Unicode escape can represent the same decoded string. Original: "a". Modified: "\u0061". Differences: [].
Compare arrays by index
Array positions matter. Each index is compared with the same index in the other document, and indexes are visited in ascending numeric order. Inserting an item at the beginning shifts every existing value:
Original JSON
["a","b","c"]
Modified JSON
["x","a","b","c"]
Differences
[
{
"type": "changed",
"path": "/0",
"before": "a",
"after": "x"
},
{
"type": "changed",
"path": "/1",
"before": "b",
"after": "a"
},
{
"type": "changed",
"path": "/2",
"before": "c",
"after": "b"
},
{
"type": "added",
"path": "/3",
"after": "c"
}
]
The result contains three changed indexes and one trailing addition. SyntaxDock does not align sequences, match items by identity, or detect moves. A comparison like this should not be read as four independent edits made by a person; it records what differs at each position.
Replacing an item changes its index. Original: ["a","b"]. Modified: ["a","c"]. Differences: [{"type":"changed","path":"/1","before":"b","after":"c"}].
Appending an item adds the new index. Original: ["a"]. Modified: ["a","b"]. Differences: [{"type":"added","path":"/1","after":"b"}].
Removing the final item removes that index. Original: ["a","b"]. Modified: ["a"]. Differences: [{"type":"removed","path":"/1","before":"b"}].
Swapping items produces two index changes, with no move entry. Original: ["a","b"]. Modified: ["b","a"]. Differences: [{"type":"changed","path":"/0","before":"a","after":"b"},{"type":"changed","path":"/1","before":"b","after":"a"}].
Read JSON Pointer paths and escaped names
A path such as /users/0/name identifies a member inside the first array item. These are JSON Pointer paths. In a member name, a literal slash becomes ~1 and a literal tilde becomes ~0:
Original JSON
{"a/b":{"~key":"<example> & text"}}
Modified JSON
{"a/b":{"~key":"updated"}}
Differences
[
{
"type": "changed",
"path": "/a~1b/~0key",
"before": "<example> & text",
"after": "updated"
}
]
The first segment refers to the single key a/b, and the next refers to ~key. The slash inside that first key is not another nesting level. The HTML-like value remains ordinary JSON string data.
The empty pointer string identifies the complete document. A slash on its own identifies a property whose name is empty:
A scalar root change uses an empty path. Original: 1. Modified: 2. Differences: [{"type":"changed","path":"","before":1,"after":2}].
An empty-name property uses a different path. Original: {"":1}. Modified: {"":2}. Differences: [{"type":"changed","path":"/","before":1,"after":2}].
For the formal escaping and evaluation rules, see RFC 6901: JSON Pointer. Pointer paths locate values; they are not JSONPath queries.
Distinguish missing properties from null
JSON null is an explicit value. A property with that value is present, so adding it, removing it and replacing its value produce different entries:
An absent property becomes a present null. Original: {}. Modified: {"note":null}. Differences: [{"type":"added","path":"/note","after":null}].
A present null becomes absent. Original: {"note":null}. Modified: {}. Differences: [{"type":"removed","path":"/note","before":null}].
A present null is replaced by a string. Original: {"note":null}. Modified: {"note":"ready"}. Differences: [{"type":"changed","path":"/note","before":null,"after":"ready"}].
Two null roots compare equally. Original: null. Modified: null. Differences: [].
Read type replacements as one change
When an object becomes an array at the same location, comparison records one replacement. It does not report each member of the old object as removed and each array item as added:
Original JSON
{"value":{"enabled":true}}
Modified JSON
{"value":["enabled"]}
Differences
[
{
"type": "changed",
"path": "/value",
"before": {
"enabled": true
},
"after": [
"enabled"
]
}
]
These type, path, before and after entries describe differences. They are not RFC 6902 JSON Patch operations, and the tool does not generate or apply a patch.
Separate invalid input from empty differences
Both documents must be strict JSON. Objects, arrays, strings, numbers, booleans and null can be roots. Comments, trailing commas and JSON5 syntax are rejected:
Comment example: {"a":1/*comment*/}. Diagnostic: json.syntax.invalid.
Trailing comma example: {"a":1,}. Diagnostic: json.syntax.invalid.
JSON5-style example: {name:'Ada'}. Diagnostic: json.syntax.invalid.
Whitespace-only example (three spaces): . Diagnostic: json.input.empty. Empty input is also rejected.
The diagnostic identifies the affected Original or Modified document. If either input is invalid, there is no comparison output. An error must not be interpreted as the successful empty-differences result [].
Understand input limits, display limits and privacy
The input limit is 2 MiB (2,097,152 UTF-8 bytes) per document. This is a byte limit, so some characters occupy more than one byte. An oversized input is rejected before parsing with jsondiff.input.too_large.
The tool counts every structural difference but displays only the first 1,000 entries. For 1,001 changed array positions, the summary is 1,001 differences found; Changes and Changed are 1,001, Added and Removed are zero, and Displayed is 1,000. The informational diagnostic says: 1,001 differences were found. Showing the first 1,000. Truncation limits the displayed entries, not the total count.
Original JSON, Modified JSON, difference values and pointer paths are processed locally in your browser. SyntaxDock does not upload, log or persist this content. Copying a result deliberately places it on your clipboard; the tool does not automatically redact its values.
Try these comparisons in JSON Diff. To select particular values from a single document, use JSONPath Tester and the JSONPath syntax guide.