How to Compare Two JSON Files

By Ramanathan Aug 26, 2026 1 min read JSON Diff

Comparing two JSON payloads by eye is error-prone — a reordered key or different indentation looks like a change when the data is identical. A structural diff compares the meaning, not the text. Here's how to read one.

Structural, not textual

A JSON diff parses both documents and compares them by key and index. That means whitespace, indentation, and key order never register as differences — only the data does:

{ "b": 2, "a": 1 }

is equal to { "a": 1, "b": 2 }, even though the text differs.

Three kinds of change

Every difference is reported by its path and falls into one of three types:

  • Added — the key or index exists only in the right (changed) document.
  • Removed — it exists only in the left (original) document.
  • Changed — both have it, but the value or type differs.

A path like $.roles[1] points straight at the second element of the roles array, so you can find it instantly in the source.

Arrays compare by position

Array elements are matched index by index. Inserting an item near the front shifts everything after it, so each following element shows as changed — worth remembering when you diff ordered lists.

Related

Working with JSON? See JSONPath Tester to query a document, and JSON Formatter to clean one up first.

Try it

Paste both versions and see exactly what changed — everything runs in your browser, nothing uploaded.

About the author

Ramanathan · Software Engineer & Solutions Architect

I'm a Software Engineer and Solutions Architect with 20+ years of experience building enterprise applications across BFSI, Healthcare, Retail, Manufacturing, and Industrial Automation. I've spent those two decades living in JSON, tokens, regexes, and config files — so I built the fast, private, no-login developer tools I always wanted to reach for myself.

Last updated: Aug 26, 2026