JSON Diff and Compare

Paste two versions of a JSON document to see exactly what changed, path by path and line by line. Key order, indentation and number notation are ignored, so only real changes show up.

Original
Changed

Nothing leaves your browser. Shortcut: Ctrl/⌘ + Enter runs the main action.

What is a JSON diff?

A JSON diff compares two JSON documents and reports the differences between them. A plain text diff is not enough for JSON, because the same data can be written in many ways: keys in a different order, different indentation, 1.0 instead of 1. A structural JSON diff parses both sides first and compares the data, so it only reports changes that a program reading the JSON would notice. This tool shows both views: a list of changed paths such as env.LOG_LEVEL and a side-by-side view with the changed words highlighted.

How to compare two JSON files

  1. Paste the original on the left and the changed version on the right, or open or drop a file on each side.
  2. The comparison runs automatically. Compare structure (default) ignores key order and formatting; Compare text compares the files as written.
  3. Read the summary and the list of changed paths, then scroll the side-by-side view or use Previous / Next to jump between changes.

Example

Comparing these two service definitions (click Sample above to load them):

{"version": "2.4.1", "replicas": 3, "ports": [8080, 9090],
 "env": {"LOG_LEVEL": "info", "DB_POOL_SIZE": 20, "CACHE_TTL": 300}}

{"version": "2.5.0", "replicas": 5, "ports": [8080, 9090, 9443],
 "env": {"DB_POOL_SIZE": 20, "LOG_LEVEL": "debug", "REGION": "eu-west-1"}}

gives this list of changes:

ChangePathValue
changedversion"2.4.1" β†’ "2.5.0"
changedreplicas3 β†’ 5
addedports[2]9443
changedenv.LOG_LEVEL"info" β†’ "debug"
removedenv.CACHE_TTL300
addedenv.REGION"eu-west-1"

The swapped order of LOG_LEVEL and DB_POOL_SIZE is not reported, because JSON objects are unordered.

How the comparison works

Objects are compared key by key. Arrays are aligned with a longest-common-subsequence match, so an inserted or deleted element does not make every later element look changed; items that were modified rather than replaced are compared recursively, which yields paths such as items[3].price. For the side-by-side view both documents are printed with sorted keys and the same indentation, then compared line by line with the Myers diff algorithm (the one Git uses by default), and changed words inside each line are highlighted.

Invalid JSON on either side is reported with its line number; fix it with the JSON validator, or switch to Compare text. For YAML files use the YAML diff, and for any other text the text diff.

JSON diff questions

What is the difference between Compare structure and Compare text?

Compare structure parses both documents and compares the data: key order, whitespace and notation such as 1.0 versus 1 do not count, and you get a list of changed paths. Compare text compares the files line by line exactly as written, which is what you want when formatting itself matters.

How are arrays compared?

By default with "match items": the diff finds the longest run of identical items, so inserting one element at the start of a list is reported as one addition rather than every item changing. Choose "by position" to compare item 0 with item 0, item 1 with item 1 and so on.

What does Hide identical lines do?

Long stretches of unchanged lines are collapsed into a single "identical lines" bar, with three lines of context kept around every change. Click the bar to expand it, or untick the option to see both files in full.

Can I compare JSON with YAML?

Yes, in structure mode. Each side is detected separately, so you can check whether a YAML file and a JSON file contain the same data.

Is there a size limit?

Files up to 25 MB open fine. Comparisons of a few megabytes take a moment; if two files are extremely different, the middle part is shown as one replaced block to keep the page responsive.

Does the diff upload my files?

No. Both documents are compared inside your browser and never sent anywhere.