JSON Diff – Compare Two JSON Documents

Paste two JSON documents to see every value that was added, removed or changed, with its path. Key order and formatting are ignored.

Loading tool…

About the JSON Diff

A text diff compares lines, so reordering the keys of an object or re-indenting a file marks everything as changed. This tool parses both documents and compares the data. Each difference is listed with its path, such as $.owners[1].role, and one of four kinds: added, removed, changed (same type, other value) and type changed (for example the string "30" became the number 30). Numbers are compared by value, so 1, 1.0 and 1e0 are equal.

Arrays are aligned with a longest common subsequence over equal items. When one item is inserted at the start of a list, the result is a single added entry and not a change on every following index. Items that differ at the same place are compared with each other, so a changed field inside an array of objects is reported as $.items[3].price. With Ignore array order, arrays are compared as multisets: [1, 2, 3] equals [3, 1, 2], and duplicates are counted. Treat null and a missing key as equal helps with APIs that leave out empty fields.

The output is a text report, a JSON list of the differences, or a JSON Patch (RFC 6902): an array of add, remove and replace operations with JSON Pointer paths. Applied in order to the original, the patch gives the changed document; array indexes already account for the operations before them. With Ignore array order the patch appends new items at the end (/-), so the result matches the changed document in content, not in order. Both documents stay in your browser.

How to use it

  1. Paste the original JSON on the left and the changed JSON on the right.
  2. Read the list of differences: kind, path, old and new value.
  3. Turn on Ignore array order if the order of list items does not matter.
  4. Choose text report, JSON Patch or JSON list, then copy or download it.

Frequently asked questions

Does the order of keys matter?
No. JSON objects are unordered, so {"a":1,"b":2} and {"b":2,"a":1} are identical. The order of array items matters unless you turn on Ignore array order.
What is a JSON Patch?
A format from RFC 6902 that describes changes to a JSON document as a list of operations, e.g. {"op":"replace","path":"/replicas","value":5}. Libraries for most languages can apply it, and HTTP PATCH requests can carry it as application/json-patch+json.
Why is one array item shown as removed and another as added?
Items that are not equal are paired by position between the items that match. When a list loses one item and gains another in a different place, they are reported as one removal and one addition.
How are paths with special characters written?
Keys that are not plain identifiers use brackets and quotes, e.g. $["content-type"]. In the JSON Patch, paths are JSON Pointers: / separates the parts, ~1 stands for / and ~0 for ~.

Related tools