JSON Compare

Compare two JSON documents and list every difference.

Local Your input is processed locally in your browser. Found a problem? Report an issue

What JSON Compare does

JSON Compare parses two JSON documents and lists every difference as a path, so you see that $.user.email was added or $.items.2.price changed, rather than a noisy text diff. Formatting and key order do not count as differences.

Using JSON Compare

  • Paste the first JSON into the first box and the second into the second box. The differences are listed below as soon as both boxes have content.

JSON Compare examples

The built-in sample

Input

{"name":"Ada Lovelace","active":true,"tags":["math","code"],"address":{"city":"London"}}

Second input

{"name":"Grace Lovelace","active":true,"tags":["math","code"],"address":{"city":"London"}}

Output

~ changed $.name: "Ada Lovelace" → "Grace Lovelace"

This is the input that the Load sample button fills in.

Type changes, arrays and removed keys

Input

{"id":1,"tags":["a","b"],"user":{"name":"Ada","age":36}}

Second input

{"id":"1","tags":["b","a","c"],"user":{"name":"Ada"}}

Output

~ changed $.id: 1 → "1"
~ changed $.tags.0: "a" → "b"
~ changed $.tags.1: "b" → "a"
+ added $.tags.2: "c"
- removed $.user.age: 36

The number 1 and the string "1" are different values, so $.id is reported. Arrays are compared by position: swapping two items shows as two changes, and the extra third item as an addition.

Each output was produced by running this tool on the input above it.

How it works

Both documents are parsed and walked together from the root, written as $. A key present only in the second document is reported as + added, one only in the first as - removed, and a value that differs as ~ changed with the old and new values. Whitespace and key order are ignored. If nothing differs, the tool says that the two documents are identical.

Details and limits

  • Paths start at $ and use dots for both keys and array positions, so $.tags.0 is the first item of tags. A key that itself contains a dot is not distinguished from two nested keys.
  • There is no move detection in arrays. Inserting one item at the start of a long array reports every later position as changed; sort or key the arrays first if that is noise.
  • Numbers are compared after parsing, so 1.0 and 1 are equal, while 1 and "1" are not.
  • Input that is not valid JSON stops the tool, and the status line shows where the problem is. The JSON Validator page lists the usual causes.

Questions

Does key order count as a difference?

No. Objects are compared key by key, so {"a":1,"b":2} and {"b":2,"a":1} are identical. Array order does count.