GALAXY OF TOOLS

DEV SECTOR

JSON Diff

Compare two JSON documents by structure: changes by path, side-by-side view and an RFC 6902 JSON Patch.

First of these members found in an array item identifies it
Numbers closer than this count as equal

Runs entirely in your browser. Nothing you enter or upload is sent to a server.

A JSON diff that compares structure, not text

The JSON Diff tool compares two JSON documents value by value. Re-indenting a file or reordering an object’s keys produces no noise; what you see are the real differences, each with its path: a value that changed, a type that changed (the number 1042 became the string "1042"), and members or array items that were added, removed or moved.

Results come four ways: a side-by-side view with long unchanged stretches folded away, a table of changes, a plain-text summary and an RFC 6902 JSON Patch — the standard list of operations that turns the left document into the right one. A line-based tool such as the Diff Checker compares text; this one understands JSON, so it also knows when an array item merely moved.

Both documents are parsed and compared in your browser. Nothing is uploaded, so you can compare API responses, configuration files and exports that contain private data.

How to use the JSON Diff

  1. Paste the older version into Original (left) and the newer one into Changed (right), or use Load file or drag a file onto either box. Sample loads a worked example.
  2. Choose how arrays are compared under Compare arrays: Match items by key (using the Key fields, by default id, key, sku), By index or Ignore order.
  3. Optionally tick Ignore whitespace-only string changes or enter a Numeric tolerance such as 0.01.
  4. Results update as you type for documents up to about 1 MB; for bigger files press Compare.
  5. Read the Side by side view, or switch to Changes, JSON Patch or Summary and copy or download the result.

JSON Diff features

Key order never matters

Objects are compared member by member, so {"a":1,"b":2} and {"b":2,"a":1} are equal.

Three array strategies

Match items by an identifying key so an insertion does not make every later item look changed, compare by position, or treat arrays as unordered collections.

Minimal moves

In key mode, reordered items are reported as moves, and only the items outside the longest run that kept its order are moved.

Valid JSON Patch

Operations are ordered so they apply cleanly; optional test operations make the patch fail safely if the target has changed.

Errors pinpointed

If either side is not valid JSON you get the side, line, column and a caret under the problem.

Big numbers kept

Integers beyond 253, such as 64-bit IDs, are compared and written to the patch exactly.

Worked example

With the sample loaded and items matched by sku, the tool finds nine differences:

ChangePathLeft → right
Type changed$.idnumber 1042 → string "1042"
Changed$.price89.99 → 79.99
Added$.tags[2]"sale"
Removed$.variants[1] (sku TR-43)the whole item
Movedsku TR-44index 2 → 0
Changed$.variants[0].stock5 → 3
Added$.variants[2] (sku TR-45)a new item
Removed / added$.warranty / $.updatedone member dropped, one new

The reordered dimensions object is not reported. The patch starts like this:

[
  {"op":"replace","path":"/id","value":"1042"},
  {"op":"replace","path":"/price","value":79.99},
  {"op":"add","path":"/tags/2","value":"sale"},
  {"op":"remove","path":"/variants/1"},
  {"op":"move","from":"/variants/1","path":"/variants/0"},
  …

How arrays are matched

  • Match items by key pairs objects that share the first key field they contain, such as "id": 7. Plain values like tags are matched by value. Items without a key are paired in order.
  • By index compares item 0 with item 0, item 1 with item 1, and so on. Inserting one item near the start makes everything after it look changed — the right choice only when position carries meaning, like coordinates.
  • Ignore order treats an array as a bag of values. An edited item appears as one removal plus one addition, and the patch appends new items with /-.

JSON Patch operations

Paths are JSON Pointers (RFC 6901): /variants/0/stock, with ~1 for a slash and ~0 for a tilde inside a member name. Operations apply in order and the patch is atomic — if one fails, none apply.

OperationMeaning
addInsert a member or array item (/- appends to an array)
removeDelete the member or item at path
replaceSwap the value at path for a new one
moveTake the value at from and insert it at path
testStop the whole patch unless the value at path equals value

JSON Diff FAQ

How do I compare two JSON files online?

Load or paste the original on the left and the new version on the right. The JSON diff runs immediately and lists every difference by path, with a side-by-side view and a JSON Patch you can download.

Does the order of keys matter?

No. JSON objects are unordered, so keys are matched by name. Array order does matter unless you choose Ignore order or match items by key.

How do I apply the JSON Patch?

Use any RFC 6902 library — for example fast-json-patch in JavaScript, jsonpatch in Python or the patch support in Java’s Jakarta JSON Processing. Send it with the media type application/json-patch+json to APIs that accept HTTP PATCH.

Why does every array item after an insertion show as changed?

That happens when arrays are compared by index. Switch Compare arrays to Match items by key and enter the member that identifies an item, such as id or uuid.

Can it ignore tiny number differences?

Yes. A numeric tolerance of 0.01 treats 10 and 10.004 as equal. Values within tolerance are not reported and are left out of the patch.

Is my JSON uploaded?

No. Parsing and comparison happen in this browser tab and nothing is sent anywhere. To tidy a document before comparing it, use the JSON Formatter; to pull specific values out of it, try the JSONPath Tester.

You might also need