DevToolbox

JSON Diff — Compare Two JSON Documents Line by Line

A git-style unified diff of two JSON documents, pretty-printed and optionally key-sorted first.

Loading tool…

Comparing two JSON files with a plain text diff is noisy — reformatting or a reordered key lights up the whole file. This tool first normalises both sides (pretty-print with 2-space indentation, and optionally sort every object's keys), then runs a line-by-line diff and shows the result exactly like git diff: red lines for the original, green + lines for the change, with line numbers and surrounding context.

Changed lines are highlighted down to the character, so a single altered value stands out. You can expand full context or keep three lines around each change, and copy the whole thing as a unified patch. It is useful for reviewing API responses, test fixtures and config between environments.

Features

  • git-style unified diff with +/− lines and line numbers
  • Both sides pretty-printed before diffing, so formatting noise is gone
  • Optional key sort so reordered keys are not treated as changes
  • Character-level highlighting on changed lines
  • Collapsed context with hunk headers, or full-file view
  • Copy the result as a unified patch

How to use the json diff

  1. Paste the original JSON on the left and the new JSON on the right.
  2. Leave "sort keys" on to ignore key reordering, or turn it off to see it.
  3. Read the diff: − red is the original, + green is the change.
  4. Toggle full context, or copy the unified patch.

Frequently asked questions

Is this a text diff or a structural diff?

A text diff — but of normalised JSON. Both documents are parsed and re-serialised with consistent indentation (and optional key sorting) first, so you get git-style output without whitespace-only noise.

Does key order matter?

Only if you want it to. With "sort keys" enabled (the default) every object's keys are ordered alphabetically on both sides, so reordering alone produces no diff. Disable it to diff the documents as written.

How are arrays handled?

Arrays keep their order. Reordering array elements shows up as removed and re-added lines, the same way git would show it.

Is anything sent to a server?

No. Both documents are parsed, normalised and diffed locally in your browser.

Last updated September 10, 2026.

Related tools