JSON Diff

Semantic JSON compare with paths — or export an RFC 6902 JSON Patch.

Runs in your browser Instant No sign-up
Output
Original JSON
Changed JSON
Differences

Paste two versions to compare them.

Waiting for input
Processed locally · nothing is uploadedProcessed locally

How to use JSON Diff

  1. Paste the Original JSON on the left and the Changed JSON on the right. The comparison updates as you type.
  2. Pick Output: Change list for a readable list of differences, or JSON Patch for a machine-applicable RFC 6902 patch.
  3. Turn on Ignore array order when arrays are sets, such as tags or permissions.
  4. Use the swap button on the Original pane to flip the direction, and Share to send both documents in a link.

The status bar summarizes the result, for example 5 differences · 2 added · 1 removed · 2 changed, or Documents are equal.

Semantic, not textual

A text diff flags every reordered key and every reformatted line. JSON Diff parses both documents first, so it ignores formatting, whitespace and key order and reports only real data changes. Use Text Diff instead when formatting itself matters, for example when reviewing a hand-edited config file.

Reading the change list

Each change is shown with its JSONPath. Removed values start with -, added values with +, and a changed value shows both lines:

- $.owner.email: null
+ $.owner.email: "linh@example.com"
+ $.tags[2]: "privacy"
- $.limits.requests: 1000
+ $.limits.requests: 5000
- $.limits.burst: 50
+ $.public: true

Keys that aren’t plain identifiers use bracket notation, such as $["first name"]. You can paste any path into the JSONPath Tester to inspect that part of the document.

JSON Patch output

The same comparison as a patch:

op path value
replace /owner/email "linh@example.com"
add /tags/2 "privacy"
replace /limits/requests 5000
remove /limits/burst
add /public true

Paths use JSON Pointer (RFC 6901): / inside a key is escaped as ~1 and ~ as ~0, so the key a/b becomes /a~1b. When an array shrinks, removals are listed from the end (/3 before /2) so the indexes stay valid while the patch is applied in order.

Arrays and ordering

By default ["a","b","c"] and ["c","a","b"] differ at every index. With Ignore array order they are equal, because each array is treated as a multiset: an item counts as removed only if the changed array has fewer copies of it. This works for arrays of objects too, since each element is compared by its full content.

In code

// Node.js — the fast-json-patch package creates and applies RFC 6902 patches
import { compare, applyPatch } from 'fast-json-patch';
const patch = compare(original, changed);
const result = applyPatch(original, patch).newDocument;
# jq: check whether two files are equal after sorting keys
diff <(jq -S . a.json) <(jq -S . b.json)

To tidy either document before comparing, run it through the JSON Formatter.

Frequently asked questions

Does key order matter?

No. Objects are compared key by key, so {"a":1,"b":2} and {"b":2,"a":1} are equal. Numbers are compared by value, so 1 and 1.0 are equal too.

How are arrays compared?

By position: element 0 against element 0, and so on. Extra elements show up as added or removed at the end. Turn on Ignore array order to compare arrays as unordered collections, where duplicates still count.

Can I apply the result with a JSON Patch library?

Yes. Choose Output: JSON Patch to get an RFC 6902 document with add, remove and replace operations in an order that can be applied as-is. JSON Patch always compares arrays by position, so Ignore array order is not applied in that mode.

What if one of the documents is invalid?

The error panel names the input that failed (Original JSON or Changed JSON) with the exact line and column, and Jump to error moves the cursor there.

Is my JSON uploaded?

No. Both documents are parsed and compared in your browser. Nothing is uploaded.

Last updated