๐ JSON Diff Checker
By Shihab Mia ยท Updated 2026-08-03
Paste JSON into both boxes and press Compare.
A JSON diff compares two JSON values and tells you exactly what changed between them: which keys were added, which were removed, and which values were modified. Paste your original JSON in the left box and the changed version on the right, and this tool walks both structures recursively and lists every difference with the precise path to it, such as user.roles[1] or config.timeout. Everything runs in your browser, so even sensitive payloads never leave your machine.
What is the JSON Diff?
JSON (JavaScript Object Notation) is a tree of objects, arrays and primitive values. Two JSON documents can look almost identical yet differ in ways that are hard to spot by eye: a single flipped boolean, a number that became a string, or a key that quietly disappeared from a nested object. A JSON diff solves this by parsing both sides into real data structures and then comparing them node by node, rather than comparing the raw text. That means cosmetic differences like indentation, spacing or trailing newlines do not register as changes, only genuine structural and value differences do. This is what people mean by a semantic diff, as opposed to a plain text diff that only knows about lines and characters.
This tool classifies every difference into one of three kinds. An added key exists in B but not in A. A removed key exists in A but not in B. A changed value is a leaf (a string, number, boolean or null) that is present on both sides but holds a different value, or whose type changed (for example the number 1 becoming the string "1"). Each difference is reported with a dotted, bracketed path so you can locate it instantly in the source, for example items[0].price or meta.tags[3].
Arrays are compared position by position, which is the simplest correct approach: index 0 in A is compared to index 0 in B, and so on. If B has more elements, the extras are reported as added; if A has more, the extras are reported as removed. This is predictable and fast, though it means inserting an item at the front of a long array will show many positions as changed rather than as a single insertion. For configuration files, API responses and small to medium payloads, positional comparison is exactly what you want.
A JSON diff is not the same job as a JSON merge tool. This tool tells you what is different; it does not try to combine two versions into one or resolve conflicts automatically. That distinction matters most when reviewing a pull request that touches a config file, or when two team members have each edited a shared JSON fixture: you want a clear, honest list of every change before deciding what to keep, not an automatic guess. It also differs from a JSON Patch generator (RFC 6902), which outputs a sequence of add, remove and replace operations that can be applied programmatically; a diff report like this one is meant to be read by a person, not executed by a machine.
Comparing structured data by hand does not scale past a handful of fields, which is why JSON diffing shows up constantly in real engineering work: verifying that an API response matches the previous version after a backend change, checking that a configuration deploy only touched the keys you intended, or confirming a database export matches a known-good snapshot. Because the comparison happens entirely client-side in your browser using the built-in JSON parser, you can safely paste API tokens, internal config or other sensitive JSON without it being transmitted anywhere.
When to use it
- Reviewing what changed between two API responses while debugging an integration.
- Comparing a config file before and after an edit to confirm only the intended keys moved.
- Checking two versions of a JSON fixture or snapshot in a test suite.
- Spotting an accidental type change, such as a numeric id that became a quoted string.
- Auditing a settings export against a known-good baseline to find drift.
- Reviewing a pull request that edits package-lock.json, an OpenAPI spec, or another generated JSON file.
How to use the JSON Diff
- Paste the original JSON into the left box (A).
- Paste the changed JSON into the right box (B).
- Press Compare, or just edit either box to compare as you type.
- Read the added, removed and changed counts, then scan the table for each path.
- Use Swap sides to reverse the comparison, or Load sample to see an example.
Formula & method
Worked examples
A = {"name": "Ada", "age": 36, "active": true} and B = {"name": "Ada", "age": 37, "city": "London"}.
- name is "Ada" in both, so no difference.
- age is 36 in A and 37 in B, both present, value differs: Changed at path age (from 36 to 37).
- active is true in A but absent in B: Removed at path active.
- city is "London" in B but absent in A: Added at path city.
Result: 1 added (city), 1 removed (active), 1 changed (age).
A = {"roles": ["admin", "editor"]} and B = {"roles": ["admin", "viewer"]}.
- roles is an array on both sides, so compare by index.
- roles[0] is "admin" in both: no difference.
- roles[1] is "editor" in A and "viewer" in B: Changed at path roles[1] (from "editor" to "viewer").
Result: 0 added, 0 removed, 1 changed (roles[1]).
A = {"user": {"id": 1, "roles": ["admin"], "settings": {"theme": "dark"}}} and B = {"user": {"id": 1, "roles": ["admin", "editor"], "settings": {"theme": "light", "notifications": true}}}.
- user.id is 1 in both: no difference.
- user.roles is an array on both sides; roles[0] is "admin" in both, no difference.
- roles[1] does not exist in A but is "editor" in B: Added at path user.roles[1].
- user.settings.theme is "dark" in A and "light" in B, both present: Changed at path user.settings.theme (from "dark" to "light").
- user.settings.notifications is true in B but absent in A: Added at path user.settings.notifications.
Result: 2 added (user.roles[1], user.settings.notifications), 0 removed, 1 changed (user.settings.theme).
The three kinds of difference this tool reports
| Kind | Meaning | Shown in From (A) | Shown in To (B) |
|---|---|---|---|
| Added | Key or index exists in B but not in A | - | the new value |
| Removed | Key or index exists in A but not in B | the old value | - |
| Changed | Present on both sides but value or type differs | old value | new value |
How paths are written
| Structure | Example path | Reads as |
|---|---|---|
| Top-level key | age | the age field |
| Nested object | user.profile.email | email inside user.profile |
| Array element | roles[1] | the second item of roles |
| Nested array of objects | items[0].price | price of the first item |
Array diff strategies compared
| Strategy | How it matches elements | Best for | Trade-off |
|---|---|---|---|
| Positional (used here) | Index 0 vs index 0, index 1 vs index 1, and so on | Fixed-order arrays such as coordinates or column lists | Inserting an item at the front shifts and marks every later index as changed |
| LCS / patience diff | Finds the longest common subsequence of matching elements | Ordered lists where items are inserted or removed but rarely reordered | More accurate for insertions, but slower on very large arrays |
| Key-based (by id) | Matches array items using a chosen id field regardless of position | Arrays of objects with a unique id, like database records | Requires you to know and specify which field is the id |
Common mistakes to avoid
- Expecting key order to count as a difference. Objects are compared by key, not by the order the keys appear, so reordering fields in B does not register as a change. This matches how JSON objects actually work: {"a":1,"b":2} and {"b":2,"a":1} are equal.
- Confusing a value change with an add plus a remove. If a key is present on both sides with different values, that is a single Changed row, not a Removed plus an Added. A key only counts as added or removed when it is missing entirely from one side.
- Assuming arrays are matched by content. Arrays are compared by position, so inserting an item at the start can show many later positions as changed. If you need order-independent matching, sort both arrays the same way before comparing.
- Pasting JSON5 or JavaScript object literals. The parser is strict JSON: keys must be in double quotes, no trailing commas, no comments, and no single quotes. If you see a parse error, run the text through a JSON formatter first.
- Treating a diff report as a merge tool. This tool tells you what is different between A and B; it does not combine them into a merged document or resolve conflicts. Use the reported paths to decide what to keep, then edit the source yourself.
- Mixing up a missing key with a key set to null. A key that is absent and a key present with the value null are different states. If a key exists in both A and B but one side has null, that is a Changed row, not a Removed or Added row, because the key is present in both.
Glossary
- JSON
- JavaScript Object Notation, a text format for structured data made of objects, arrays, strings, numbers, booleans and null.
- Key
- The name of a field inside a JSON object, always a double-quoted string.
- Path
- A dotted and bracketed address that points to one node in the tree, such as user.tags[2].
- Leaf
- A value with no children: a string, number, boolean or null, as opposed to an object or array.
- Diff
- The set of differences between two values, here grouped into added, removed and changed.
- Semantic diff
- A comparison based on parsed structure and values rather than raw text, so whitespace and key order do not create false differences.
- JSON Patch (RFC 6902)
- A standardized format for describing changes to a JSON document as a sequence of add, remove and replace operations that a program can apply.
- Positional array diff
- Comparing array elements by their index (position 0 with position 0, and so on) rather than by matching similar content.
Frequently asked questions
How do I compare two JSON files?
Open each file, copy its contents, and paste one into the left box and the other into the right box. The tool parses both and lists every added key, removed key and changed value with its path. You can also edit either side to see the diff update as you type.
Does the order of keys matter?
No. JSON objects are unordered by definition, so this tool compares objects by key rather than by position. Reordering the fields in one document will not show up as a difference. Array elements, however, are compared by index, so their order does matter.
How are arrays compared?
Arrays are compared position by position: index 0 against index 0, index 1 against index 1, and so on. Extra elements on the B side are reported as added, and extra elements on the A side are reported as removed. This is simple and predictable, though inserting an item at the front can mark later positions as changed.
What counts as a changed value?
A value is changed when the same key or index exists on both sides but the values differ, either in value (36 vs 37) or in type (the number 1 vs the string "1"). The tool quotes strings in the output so you can tell 1 and "1" apart at a glance.
Is my JSON sent to a server?
No. The entire comparison runs in your browser using built-in JSON parsing. Nothing you paste is uploaded, logged or stored, which makes the tool safe for private API payloads, config files and other sensitive data.
Why am I getting an invalid JSON error?
The parser follows strict JSON rules: every key must be in double quotes, strings use double quotes, and trailing commas, comments and single quotes are not allowed. The error message points to roughly where parsing failed. Formatting the text with a JSON formatter first usually reveals the problem.
What is JSON Patch, and does this tool output it?
JSON Patch (RFC 6902) is a standard format that lists changes as add, remove and replace operations a program can apply automatically. This tool is built for humans to read: it shows each difference with its path and the old and new values, rather than emitting an executable patch document.
Can I make the diff ignore the order of array elements?
Not automatically; arrays are compared by position so order matters. If two arrays contain the same items in a different order and you want that treated as equal, sort both arrays the same way, for example alphabetically or by id, before pasting them in.
What is the difference between a JSON diff and a plain text diff?
A text diff compares line by line and character by character, so reformatting a file, even without changing any data, produces a wall of unrelated changes. A JSON diff parses both documents into their real structure first, so it ignores whitespace and key order and reports only genuine additions, removals and value changes.
Can I use this to compare large JSON files, like full API responses?
Yes, for typical API responses and config files up to a few megabytes this runs comfortably, since the whole comparison happens in your browser with no upload step. Extremely large files, in the tens of megabytes or more, may feel slower to parse and render because of browser memory limits rather than any limit imposed by the tool.