Skip to content
codevory

JSON Diff

Compare two JSON documents by data, not by text. Key order and number formatting are ignored, and every difference is listed with its path.

JSON Diff: the tool

Paste two JSON documents to compare them. Key order does not matter.

Original

Modified

How to use JSON Diff

  1. Paste the original document on the left and the modified one on the right, or press Example.
  2. The status bar summarises how many values were added, removed and changed.
  3. The table lists each difference with its path, the kind of change, and the value on each side.
  4. Turn on Ignore array order if the order of items is not meaningful, for example a list of tags. Swap sides reverses the comparison.

Example

Two versions of a small manifest. The formatting of maxMb (10 and 10.0) is not a difference, but the string "0.5" replacing the number 0.5 is.

Original
{"name":"codevory","version":"1.0.0","tools":["json","yaml","xml"],"limits":{"maxMb":10,"ratio":0.5},"owner":null}
Modified
{"name":"codevory","version":"1.1.0","tools":["json","yaml","csv","xml"],"limits":{"maxMb":10.0,"ratio":"0.5"},"homepage":"https://codevory.com"}
Differences
changed $.version          "1.0.0"  ->  "1.1.0"
changed $.tools[2]         "xml"  ->  "csv"
added   $.tools[3]         -  ->  "xml"
type    $.limits.ratio     0.5  ->  "0.5"
removed $.owner            null  ->  -
added   $.homepage         -  ->  "https://codevory.com"

About this tool

A text diff of two JSON files reports a change whenever the formatting differs: a different indentation, keys in another order, 1.0 instead of 1. This tool parses both documents and compares the data. Objects are compared by key, so order does not matter. Numbers are compared as exact decimals, so 10 equals 10.0 and 1e2 equals 100, while 12345678901234567890 and 12345678901234567891 are different. Strings are compared by their decoded value, so "é" equals "\u00e9".

Arrays are compared by position by default: the item at index 2 on the left is compared with the item at index 2 on the right, an extra item at the end is an addition or a removal. With Ignore array order, items are matched by content instead, as in a multiset: [1, 2, 2] differs from [1, 2] because one item has no partner. Nested arrays are then treated as unordered too.

A value that changes type, such as the number 0.5 becoming the string "0.5", is reported as a type change, because it usually breaks consumers even though it looks the same. If a document repeats a key, it is reported as a warning, and the last value is used as in JSON.parse. At most 2,000 differences are collected.

Frequently asked questions

Why does the tool say there are no differences when the files look different?

Because it compares data. Different indentation, key order, spacing, escape sequences and number spellings such as 1.0 and 1 do not change the data, so they are not reported. Use a text diff if you need to see formatting changes.

How are arrays compared?

By position by default, so reordering a list shows up as changes. Turn on Ignore array order to compare items by content instead, which suits sets such as tags or permissions.

What is a type change?

A value that is a different kind on each side: a number versus a string, null versus an object, an array versus an object. These are listed separately because they often cause bugs even when the values look alike.

Can it compare very large files?

Documents of a few megabytes work. The comparison stops collecting after 2,000 differences and says so, and the table shows the first 500 rows.

What does the path column mean?

It locates the value from the root ($). Keys follow a dot, array positions are in brackets and count from 0, and keys that are not plain identifiers use brackets with quotes. It is the same notation as in the JSON viewer.