1. Home
  2. Developer
  3. JSON Diff

JSON Diff

Structural JSON compare that shrugs off key order, with JSON Patch export.

Runs in your browser · No upload
Elements at the same position are compared.
Comma separated. Example: $.updatedAt, $.meta.* (* is one level)
Added
+1
Removed
−2
Changed
7
PathKindBeforeAfter
$.versionChanged"1.2.0""1.3.0"
$.debugRemovedtrue(none)
$.server.hostChanged"localhost""0.0.0.0"
$.server.portType3000"3000"
$.server.tlsAdded(none)true
$.tags[1]Changed"shop""store"
$.tags[2]Removed"beta"(none)
$.plugins[0].idChanged"seo""cache"
$.plugins[1].idChanged"cache""seo"
$.plugins[1].enabledChangedfalsetrue
JSON Patch (RFC 6902)
[ { "op": "replace", "path": "/version", "value": "1.3.0" }, { "op": "replace", "path": "/server/host", "value": "0.0.0.0" }, { "op": "replace", "path": "/server/port", "value": "3000" }, { "op": "replace", "path": "/tags/1", "value": "store" }, { "op": "replace", "path": "/plugins/0/id", "value": "cache" }, { "op": "replace", "path": "/plugins/1/id", "value": "seo" }, { "op": "replace", "path": "/plugins/1/enabled", "value": true }, { "op": "remove", "path": "/debug" }, { "op": "remove", "path": "/tags/2" }, { "op": "add", "path": "/server/tls", "value": true } ]

How to use

  1. Paste the original JSON on the left and the changed JSON on the right. The page opens with two versions of a config file so you can see a result right away.
  2. In the Change list, check which path ($.server.port) was added, removed or changed. A value whose type changed (the number 3000 to the string "3000") is marked Type separately.
  3. Choose how arrays are compared and which paths to ignore.
  4. Switch to Side by side for a line-level view, or copy or save the JSON Patch below.

Text diff vs structural diff

A text diff matches characters and lines as they are, so reordered keys or different indentation all show up as changes. This tool parses the JSON first and compares values. Key order, whitespace and line breaks do not matter, and 1 and 1.0 are the same number. A key whose value is null is not the same as a missing key: {"a": null} against {} is reported as a removed.

Array comparison

Mode Compares Use it for
By index Elements at the same position Arrays where order matters
Match by key Elements whose key value (default id) is equal; elements without the key are compared by position Lists of objects that may be reordered
Ignore order The array as a set, comparing only how many of each value there are Value lists such as tags or permissions

Comparing [1,2,3] with [3,2,1], by index reports $[0] and $[2] as changed, match by key gives the same result because the elements have no key, and ignore order reports no difference. In the sample, matching plugins by key (id) ignores the reordering of seo and cache and reports only cache.enabled going from false to true, as $.plugins[0].enabled (the path uses the right-hand array’s position; removed elements use the left-hand position). Comparing the same sample by index pairs elements by position instead, giving three items: $.plugins[0].id, $.plugins[1].id and $.plugins[1].enabled.

Options

Option Effect
Ignore case Lowercases strings before comparing
Ignore surrounding spaces Trims both ends of strings before comparing
Paths to ignore Comma separated: $.updatedAt, $.meta.*, $.items[0].id, $["first-name"]. * is a one-level wildcard, and everything below a listed path is ignored

Timestamp-like fields such as deploy time, request ID or modified date change every time and hide the real differences. List one, for example $.updatedAt, and only that item drops out. Ignoring updatedAt in the sample takes the change list from 11 items to 10.

JSON Patch

The change list can be exported as JSON Patch (RFC 6902). Changed values become replace, new ones add, and vanished ones remove. Paths are JSON Pointers (RFC 6901), where ~ in a key is written ~0 and / is written ~1, so the key a/b becomes /a~1b. When several array elements are removed, the highest index goes first so the indexes do not shift.

Changing {"user":{"name":"a","tags":["x","y"]}} into {"user":{"name":"b","tags":["x"]}} gives:

[
  { "op": "replace", "path": "/user/name", "value": "b" },
  { "op": "remove", "path": "/user/tags/1" }
]

Use it as the body of a REST PATCH request (Content-Type: application/json-patch+json) or to record a change history. Key and order-insensitive modes mix left and right indexes, so compare by index when you need a patch that applies as-is.

Limits

  • Each input can be up to 5 MB. The table shows up to 1,000 changes and reports the count of the rest; the JSON Patch has everything.
  • Side by side is a line comparison with keys sorted and does not follow the array mode or the case option.
  • Integers beyond 2^53 already lose their last digits when the JSON is read, so send large IDs as strings.

To find syntax errors first, use the JSON Formatter. To turn a response into types, use JSON to TypeScript. To change the format, try JSON to YAML.

The JSON you enter is processed in your browser only and is never sent to a server.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.