Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

JSON Diff & Compare

Structural JSON compare with JSON Patch and Merge Patch export — and apply patches too.

Developer No upload Works offline Free, no sign-up

Ctrl/⌘ + Enter compares

Next steps

About the JSON Diff & Compare

Paste two versions of a JSON document — an API response before and after a change, two config files, two exports — and see exactly what differs: which paths were added, removed, changed or moved. The comparison is structural, not textual: the order of keys and the formatting do not matter, and numbers are compared by value, so 1.0 equals 1 but 12345678901234567890 is not mistaken for 12345678901234567891 (JavaScript's JSON.parse cannot tell those two apart).

View the result side by side, as a unified diff, or as a list of paths. Then export the difference as an RFC 6902 JSON Patch or an RFC 7396 JSON Merge Patch — or switch to Apply a patch to run a patch against a document.

How to use it

  1. Paste the original JSON on the left and the changed JSON on the right (or open two files, or press Load sample).
  2. Choose how arrays are compared: detect inserted and removed items (default), compare by position, or match objects by a key such as id.
  3. Press Compare (or Ctrl/⌘ + Enter). Switch between Side by side, Unified and Changes views; unchanged stretches are folded — click a fold to open it.
  4. Under Export the difference, pick JSON Patch or Merge Patch, then copy or download it.
  5. To use a patch, choose Apply a patch, paste a document and a patch, and press Apply patch.

Examples

Key order is ignored, values are not
Input
Left:  {"id": 7, "plan": "free"}
Right: {"plan": "pro", "id": 7}
Result
[
  { "op": "replace", "path": "/plan", "value": "pro" }
]

Only plan changed. The same change as a merge patch is {"plan": "pro"}.

An inserted array item
Input
Left:  {"tags": ["beta", "mobile"]}
Right: {"tags": ["beta", "desktop", "mobile"]}
Result
[
  { "op": "add", "path": "/tags/1", "value": "desktop" }
]

Comparing by position instead would report /tags/1 as changed and /tags/2 as added.

Matching objects by id
Input
Left:  [{"id": 1, "n": "a"}, {"id": 2, "n": "b"}]
Right: [{"id": 2, "n": "b"}, {"id": 1, "n": "A"}]
Result
[
  { "op": "replace", "path": "/0/n", "value": "A" },
  { "op": "move", "from": "/0", "path": "/1" }
]

With Match objects by key = id, the items are paired by id, so the reorder shows up as a move rather than two changed objects.

Common uses

  • Seeing what changed between two API responses, webhook payloads or database exports.
  • Reviewing configuration changes (feature flags, app settings, package.json, Terraform or Kubernetes JSON) before deploying.
  • Generating a JSON Patch for an HTTP PATCH request (application/json-patch+json) or a merge patch (application/merge-patch+json).
  • Checking that a patch does what you expect by applying it to a sample document.

How the comparison works

  • Objects are compared member by member, whatever their order. A member only on the left is removed, only on the right added.
  • Numbers are compared by exact decimal value: 1, 1.0 and 1e0 are equal, and large integers are never rounded.
  • Strings must match exactly (case, spaces and Unicode code units).
  • Arrays — Detect inserted and removed items finds the longest run of identical items (Myers' diff algorithm), then pairs the remaining items with their most similar counterparts so that a changed object shows its changed fields. Compare by position pairs item 0 with item 0, 1 with 1, and so on. Match objects by key pairs objects with the same value of the key you name (for example id) and reports items that changed position as moved.
  • A value that changes type (say, a string becomes an object) is reported as one change of the whole value.

JSON Patch (RFC 6902) or Merge Patch (RFC 7396)?

JSON Patch is a list of operations — add, remove, replace, move, copy and test — whose paths are JSON Pointers such as /orders/0/status. It can express every change, including changes inside arrays, and the operations are applied in order: the patch generated here removes array items from the highest index down, so each index is still correct when it is used. Tick Include test operations to add a test before each replace and remove; a server that applies the patch then refuses it if the document has changed in the meantime.

Merge Patch is a partial document: members to change, with null meaning "delete this member". It is easy to read, but it replaces arrays as a whole and it cannot set a value to null — the tool warns you when the difference contains such a change.

Limitations

  • Line numbers in the side-by-side and unified views refer to both documents pretty-printed with 2-space indentation and the left document's key order, not to the text as you pasted it.
  • Detecting inserted items explores up to 1,500 insertions and deletions per array; arrays that differ more than that are compared by position (the result says so).
  • Duplicate keys inside one object are reduced to their last value (as JSON.parse does), and a warning is shown.
  • Both documents are compared in your browser; very large files (tens of megabytes) can take a few seconds on older phones, and the line views show the first 4,000 lines of the difference at a time.

Privacy

Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.

Frequently asked questions

Are my JSON documents uploaded?

No. Parsing, comparing and patching all run in your browser, and the page keeps working offline once it has loaded.

Why do two documents with different key order show no differences?

Because JSON objects are unordered: RFC 8259 defines an object as an unordered collection of members, so {"a":1,"b":2} and {"b":2,"a":1} mean the same thing. Array order does matter.

Is 1.0 different from 1?

Not here. They are the same number, which is also how a JSON Patch test operation compares numbers. The comparison is exact, though: 0.1 + 0.2 style rounding never happens, and very large integers are compared digit by digit.

Why does my patch use "move"?

Only when arrays are matched by a key: if an item with the same id is now at a different position, a move operation reorders it instead of deleting and re-adding the whole object.

Can I apply the patch in my own code?

Yes. The JSON Patch follows RFC 6902, so libraries such as fast-json-patch (JavaScript), jsonpatch (Python) or json-patch (Go) can apply it. Merge patches follow RFC 7396.

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.