Home / JSON tools / JSON compare

JSON Compare

Compare two JSON documents and decide what counts as a difference: ignore array order, chosen keys or letter case, or match array items by an id.

Options

Result

Semantic comparison

A text comparison of two JSON files reports every line that differs, even if the data is the same. A semantic comparison reads the JSON and compares the data. Key order never matters, and the options below let you decide what else should be ignored. The example is set up with an id match and an ignored updatedAt key, so you can see how they work.

The options

  • Ignore array order: two arrays with the same items in a different order are equal. Use it for tags, permissions and other sets. Duplicates still count, so [1, 1, 2] is different from [1, 2].
  • Ignore letter case: "Yes" and "yes" are the same text.
  • Trim spaces: text with extra spaces at the ends is the same as the trimmed text.
  • Ignore keys: a list of key names, such as updatedAt, requestId, separated by commas. These keys are left out at every depth. You can also give a full path, such as $.meta.generatedAt, to ignore one place only.
  • Match array items by key: for arrays of objects such as users or products, enter the key that identifies each item, for example id. Items are then paired by that value, not by position, so a new item at the top of the list does not make every other item look changed. The differences are reported as $.users[id=3].name.

When to use each

SituationOption
An API returns a list in a different orderMatch by key, or ignore array order
Responses carry timestamps or request idsIgnore keys
Values differ only in capital lettersIgnore letter case
You want to see a change in the position of itemsLeave the options off

What is not ignored

A value that changes type, such as 1 becoming "1", is a difference, as is null against a missing key. The number 1 and the number 1.0 are the same, because JSON does not tell them apart. JavaScript keeps numbers with about 15 digits of precision, so a number larger than that is rounded before it is compared, and the tool warns you if it sees one.

For the basics, see JSON diff. To read the result as a full side by side view, use the JSON diff viewer, and see the guide for more on how comparison works.

Frequently asked questions

How do I compare JSON and ignore the order of array items?

Tick Ignore array order. Items are matched by their content, so only items that are really missing or new are reported.

How do I ignore certain fields such as timestamps?

Type the key names in the Ignore keys box, separated by commas. They are ignored at every depth.

What does Match array items by key do?

It pairs the items of two arrays by the value of a key such as id, so that an item that moved is still compared with itself.

Does the comparison care about key order?

No. Objects are always compared by key, never by position.