Saved

Press the star next to a tool's name to save it.

All my tools

JSON Compare

Use this JSON compare tool to find the real differences between two JSON documents. It ignores key order and lists every added, removed and changed path. Nothing leaves your browser.

Restored your last values ·

Key order never matters. Choose "Ignore order" to match array items by content.

Your JSON stays in your browser. Nothing is uploaded.

Result

–

Paste two JSON documents and press Compare.

Recent results

This JSON compare tool checks two JSON documents against each other and lists every difference as a path: what was added, what was removed and what changed. Paste the old and the new document, press Compare, and read the result as a table instead of scanning two long texts by eye.

A plain text diff is a poor fit for JSON. Two files can hold exactly the same data and still differ line by line, because the keys are in another order or the indentation changed. This tool reads both documents as data first, so only real differences show up. Everything runs in your browser and nothing is uploaded.

How to use JSON compare

  1. Paste the first document into the left box and the second into the right box.
  2. Choose how arrays are compared: by position, or ignoring order.
  3. Press Compare.
  4. Read the summary, then the table of differences. Each row gives the type, the path, the old value and the new value.
  5. Press "Copy report" to take the list away as plain text.

What counts as a difference

JSON has four primitive types, strings, numbers, booleans and null, and two structured types, objects and arrays [1]. The tool walks both documents together and reports three kinds of change.

  • Added: a key or array item that exists only in the second document.
  • Removed: a key or array item that exists only in the first document.
  • Changed: a value that is different, or a value whose type is different, such as the number 1 against the string "1".

Key order is ignored

An object is a set of name and value pairs [1]. The standard says that parsers differ on whether member order is visible to the program, and that software which does not depend on order behaves the same everywhere [1]. This tool follows that advice. Objects with the same keys and values in a different order are equal, and the keys are always compared in sorted order so the report is steady.

Arrays: by position or ignoring order

An array is an ordered list, so by default the tool compares item 0 with item 0, item 1 with item 1 and so on. If the second list is longer the extra items show as added, and if it is shorter the missing items show as removed. That is the right choice when position matters, such as a list of steps.

When order does not matter, such as a list of tags or ids, choose "ignore order". The tool then matches items by their content, whole objects included, and reports only the items that have no partner. Because the position of such an item is not meaningful, its path ends in [*].

Reading the paths

Paths start at $, which stands for the whole document. A dot adds an object key, so $.user.name is the name inside user. Square brackets add an array index, so $.items[2] is the third item. A key that is not a simple name, such as one with a space, is written in brackets and quotes, for example $["first name"]. The paths are for reading, and they are close to the JSONPath style that many tools use.

PathMeaning
$.priceThe price key at the top level
$.items[0].idThe id of the first item
$.tags[*]An unmatched item in a list compared without order
$["first name"]A key containing a space

Worked example

Compare {"a":1,"b":2,"c":3} with {"a":1,"b":5,"d":4}. The tool reports three differences: $.b changed from 2 to 5, $.c was removed and $.d was added. The key a is equal in both, so it does not appear. If the second document were written as {"d":4,"b":5,"a":1}, the answer would be the same.

Limits and cautions

  • Numbers are compared as JavaScript numbers, so 1 and 1.0 are the same and very large integers can lose precision.
  • If an object repeats a key, only the last value is kept, because that is how the browser parser works. The standard says such documents behave unpredictably [1].
  • Comments and trailing commas are not JSON and will give a parse error that names the problem.
  • At most 500 differences are shown in the table. The summary still counts all of them.

When to use it

Use JSON compare to check an API response before and after a change, to review a configuration file edit, to compare a saved fixture with a live result, or to confirm that two exports hold the same data. For a line-by-line view of plain text, a text diff is better. For JSON, a structural diff tells you what changed rather than where the lines moved.

Tips for comparing JSON files

  • Format both documents the same way before you paste them if you also want to read them. The comparison itself does not depend on spaces or line breaks.
  • Compare small pieces when two documents are very large. Paste only the object you care about so the report stays short.
  • Watch for type changes. A field that moves from the number 5 to the string "5" is a real change for most programs even though the two look alike.
  • For records with an id, such as a list of users, sort or match them by id first. Comparing by position will report a change in every row after an insertion.
  • Use "ignore order" for sets of values and the default for sequences.

The copied report has one line per difference, written as the type, the path and the old and new values. It is plain text, so it can go straight into a ticket or a code review comment.

What next

Use this often? Add JSON Compare to your Home screen.

Frequently asked questions

How does JSON compare work?

It parses both documents, walks them together and lists every key or item that was added, removed or changed, each with its path.

Does key order matter when I compare JSON?

No. Objects with the same keys and values are equal whatever their order. Array order matters unless you choose to ignore it.

How do I compare JSON arrays without caring about order?

Choose "Ignore order". Items are matched by their content, and only items without a partner are reported.

Why is 1 different from "1"?

They have different types, a number and a string, so the tool reports a change.

Is my JSON sent to a server?

No. Both documents are read and compared in your browser.

What went wrong?

We only receive the reason you pick, never what you typed into the tool.

Thanks for your feedback.

More Developer Tools