Skip to content

JSON Diff

This JSON diff compares two versions of a document and shows what changed, path by path, with a line diff underneath.

Original
Changed
+ 1 added− 0 removed~ 4 changed
  1. $.env.LOG_LEVEL"info" → "warn"
  2. $.env.RETRY_LIMIT3
  3. $.features[1]"gift-cards" → "klarna"
  4. $.image"registry.example.com/checkout:1.8.0" → "registry.example.com/checkout:1.9.0"
  5. $.replicas2 → 4
 {   "env": {−    "LOG_LEVEL": "info",−    "PAYMENT_TIMEOUT_MS": 3000+    "LOG_LEVEL": "warn",+    "PAYMENT_TIMEOUT_MS": 3000,+    "RETRY_LIMIT": 3   },   "features": [     "apple-pay",−    "gift-cards"+    "klarna"   ],−  "image": "registry.example.com/checkout:1.8.0",+  "image": "registry.example.com/checkout:1.9.0",   "name": "checkout-service",−  "replicas": 2+  "replicas": 4 }
5 differencesRuns in your browser

Load from a URL

Your browser fetches it directly, so the server must allow cross-origin requests (CORS).

How to compare JSON

  1. Paste the old version into Original and the new one into Changed.
  2. The diff runs as you type; Compare or Ctrl + Enter runs it again.
  3. Read the counts, the changed paths, then the line diff.

Both sides are kept between visits.

Example

Original:

{
  "plan": "pro",
  "seats": 5,
  "addons": ["sso", "audit-log"],
  "billing": { "cycle": "monthly", "currency": "USD" }
}

Changed:

{
  "billing": { "currency": "USD", "cycle": "yearly" },
  "plan": "pro",
  "seats": 8,
  "addons": ["audit-log"],
  "trialEnds": null
}

Result:

+ 1 added   − 1 removed   ~ 3 changed

$.addons[0]       "sso" → "audit-log"
$.addons[1]       "audit-log"              removed
$.billing.cycle   "monthly" → "yearly"
$.seats           5 → 8
$.trialEnds       null                     added

billing moved and its keys swapped places, which is not a change. Removing "sso" from the front of addons shows as a change at [0] and a removal at [1], because arrays are compared by position; the line diff shows it as one removed line.

How JSON diff compares values

  • Objects by key, so key order never appears in the list.
  • Arrays by index.
  • Values by type and value: 1 and "1" differ; 1.0 equals 1 and 1e3 equals 1000.
  • null on one side and a missing key on the other is listed as added or removed.
  • An object or array on one side only is listed once, with its whole value.

Whitespace never matters: both sides are parsed and re-indented with 2 spaces for the line diff, so there is no need to run them through the JSON formatter first.

Ignore key order

On by default: both documents are sorted by key before the line diff, so moved keys don’t flood it. Off shows each document in its own order; the path list finds the same changes either way. Sort JSON keys sorts a file for good.

Limits

The list shows the first 500 changes; the counts include all. Past 4,000 line edits, the line diff stops aligning and shows the old text, then the new. Both sides must be valid JSON: the status bar names the side and line with the error, and the JSON validator explains it. To explore one document, use the JSON viewer.

Questions

Can I compare two JSON files?

Yes. Press Open file once per file. A file goes into Original while that side is empty or still shows the sample, and into Changed after that.

How do I compare arrays when the order does not matter?

Sort both arrays the same way before you paste them. Arrays are compared by position, so ["a", "b"] against ["b", "a"] shows two changes, and there is no option to ignore array order.

Why does the line diff show my numbers differently?

Both sides are parsed and printed again for the line diff, so 1e3 shows as 1000 and 1.50 as 1.5. The path list compares values, and those are equal.

Related tools

Esc