InTab

Blog

How to compare two JSON files and find every real difference

By Uxair Ijaz · 2026-11-08 · 3 min read

Comparing two JSON files sounds trivial until you try it: two files that differ only in key order and spacing show dozens of fake differences, while a change that actually matters — "1" becoming 1, or a field silently disappearing — can hide inside a wall of green. The fix is a three-step routine: format both sides the same way, sort the keys, then diff.

Why a plain diff lies about JSON

A text diff compares characters. JSON does not care about characters that only exist for humans:

  • Key order: {"a":1,"b":2} and {"b":2,"a":1} are the same JSON — object keys are unordered by definition — but a text diff calls every line changed.
  • Whitespace: the same file minified and beautified differs in every character of padding.
  • Number formats: 1 and 1.0 are written differently and can be the same value to your code — or not, depending on the language. That is a difference you want to see.

So before comparing, remove the noise and keep the substance.

Step 1: format both files the same way

Paste each file into the JSON Formatter, tick Sort keys, choose the same indentation (2 spaces works well), and choose Beautify. Sorting keys is the step most people skip; it is what makes two files with the same data line up line by line. Copy both results.

Step 2: diff the formatted versions

Open the Diff Finder, paste the old version into Original, the new one into Changed, and click Compare:

  • Lines shows which lines were added, removed or touched — best for a first pass over configs and API responses.
  • Words zooms into a changed line and marks the exact values that moved, for example 30 → 14.
  • Chars is for keys, IDs and short strings.
  • Side by side reads like a review; Unified is better for copying into a pull-request comment.

Step 3: read the changes like a reviewer

The diffs that matter in JSON are usually one of these:

Change Why it matters
"status": "pending" → "status": "paid" An enum value changed — the interesting case
"1" → 1 String became number; strict APIs and typed languages will notice
A key removed The field is gone, not just empty — code reading it breaks
null → "" or 0 "unknown" became a real (wrong-looking) value
An array reordered Sorting keys does not sort arrays; reorder may be intended or a bug

Without a tool: the terminal way

jq -S . old.json > old.sorted.json
jq -S . new.json > new.sorted.json
git diff --no-index old.sorted.json new.sorted.json

jq -S sorts keys at every depth; git diff --no-index diffs any two files, in or out of a repository. Same routine, more typing, and the result is text-only — no colours marked by word, and nothing about your files leaves your machine either way if the tools run locally.

When a text diff is not enough

Text diffs cannot tell you that a nested block moved, or that two values swapped positions inside an array of objects. If a change is hard to interpret, reformat the suspicious section with Sort keys and diff again at Words level — most apparent mysteries collapse into one changed value. For genuine semantic comparison (ignoring order entirely, matching objects by ID), you need a purpose-built library in your language of choice; for files you meet in daily work, format-sort-diff covers nearly everything.

FAQ

What is the fastest way to compare two JSON files online? Format both in the JSON Formatter with Sort keys on, then paste them into the Diff Finder and compare at Lines, then Words. Both run in your browser; the files are never uploaded.

Why does my diff show the whole file as changed? Key order or indentation differs between the two files. Re-format both with the same settings and sorting, and the false positives disappear.

Does sorting keys change what my program reads? No. JSON objects are unordered by definition — {"a":1,"b":2} and {"b":2,"a":1} are the same value to every conforming parser. (Arrays are ordered; sorting those changes meaning, and the formatter's Sort keys does not touch them.)

How do I compare two JSON files in VS Code? Select the first file, then Select for Compare; right-click the second, Compare with Selected. Format both with Sort keys first (using a formatter extension or this site) or you will diff noise.

Can it compare JSON copied from a log or an API response? Yes. The formatter repairs escaped stringified JSON, strips log text around the payload and handles several JSON objects in a row (NDJSON) before you diff.

Is there a JSON diff checker that keeps my data private? The Diff Finder comparison runs entirely in your browser tab — no account, no upload, and it keeps working offline once loaded.

Tools in this article

  • Diff Finder: Compare two texts or JSON documents line by line or word by word. A free JSON diff checker.
  • JSON Formatter: Beautify, minify, validate and view JSON online. Handles escaped and stringified JSON.
  • Text Diff Checker: Paste two versions of a text and see exactly which words changed.