Compare JSON
A JSON diff tool compares two JSON objects and highlights the differences between them. Paste your original and modified JSON below to see added, removed, and changed values with the exact path to each change.
How JSON Diffing Works
A JSON diff compares two JSON documents structurally, not as raw text. Instead of checking line by line, it walks through both objects recursively and compares values at each key path. This means changes are reported with the exact location — like address.city or tags[2] — regardless of formatting or whitespace.
The Comparison Process
- Parse both inputs into JavaScript objects.
- Collect all keys from both objects (union of key sets).
- For each key:
- If it exists only in the original → removed
- If it exists only in the modified → added
- If it exists in both and values differ → changed
- If the value is an object or array → recurse into it
- For arrays: compare element by element at each index position.
What the Colors Mean
- + Added (green) — keys or array elements present in the modified JSON but not in the original
- − Removed (red) — keys or array elements present in the original but not in the modified
- ~ Changed (yellow) — keys that exist in both but have different values
When to Use a JSON Diff Tool
API Debugging
Compare expected vs. actual API responses to find unexpected changes in structure or values. Especially useful when an endpoint starts returning different data after a deployment.
Configuration Review
Spot differences between config files across environments (dev, staging, production). Catch missing keys or changed values before they cause issues in production.
Data Migration
Verify that records were transformed correctly during migration. Compare source and destination records to confirm no data was lost or corrupted.
Schema Validation
Check whether a JSON response matches the expected schema by comparing against a reference document. Useful for detecting breaking API changes.
Code Review
Review changes to JSON fixtures, translation files, or feature flags in pull requests. A structural diff is easier to read than a text diff for deeply nested objects.
ETL Pipeline Testing
Compare input and output of data transformation steps to verify that mappings, filters, and enrichments work as expected.
JSON Diff vs. Text Diff
A text diff (like git diff) and a JSON diff solve different problems:
| Aspect | Text Diff | JSON Diff |
|---|---|---|
| Comparison unit | Lines of text | Keys and values |
| Whitespace/formatting | Shows as changes | Ignored (compares parsed data) |
| Key reordering | Shows as changes | Ignored (objects are unordered) |
| Change location | Line number | Key path (e.g., user.address.city) |
| Nested changes | Hard to trace | Shows exact nested path |
| Best for | Source code, prose | Structured data, API responses, configs |
Use text diff for code reviews. Use JSON diff when you care about data changes, not formatting.
JSON Patch and Merge Patch Standards
Two RFC standards formalize how to describe and apply JSON changes:
JSON Patch (RFC 6902)
A JSON Patch document is an array of operations that describe exact changes to apply to a target document:
[
{ "op": "replace", "path": "/age", "value": 31 },
{ "op": "remove", "path": "/email" },
{ "op": "add", "path": "/phone", "value": "555-1234" },
{ "op": "replace", "path": "/address/city", "value": "San Francisco" }
]
Operations include add, remove, replace, move, copy, and test. Paths use JSON Pointer syntax (RFC 6901). JSON Patch is commonly used in REST APIs with the PATCH HTTP method.
JSON Merge Patch (RFC 7396)
A simpler alternative — you send a partial JSON object with only the fields to change:
{
"age": 31,
"email": null,
"phone": "555-1234",
"address": { "city": "San Francisco" }
}
Fields set to null are removed. Present fields are added or replaced. Absent fields are left unchanged. Simpler to write but less expressive than JSON Patch — it cannot represent array modifications or move operations.
Common Pitfalls When Comparing JSON
- Key order looks different but data is identical. JSON objects are unordered by specification.
{"a":1,"b":2}and{"b":2,"a":1}are the same object. Use a structural diff, not a text diff. - Formatting differences. Minified JSON and pretty-printed JSON with the same content are identical. Text diffs show every line as changed; JSON diffs correctly show zero differences.
- Number type mismatches.
1and1.0may or may not be equal depending on the tool. In JavaScript,JSON.parse("1")andJSON.parse("1.0")produce the same value. - Array insertion shifts everything. Arrays are compared by index. Inserting an element at position 0 makes every subsequent element appear "changed." For array-heavy data, consider tools that support LCS (longest common subsequence) diffing.
- Null vs. missing key.
{"name": null}is structurally different from{}. The first has a key with a null value; the second has no key at all. Most diff tools treat these as different states. - String encoding.
"café"and"caf\u00e9"are the same string in JSON but may look different in raw text. JSON diff tools parse first, so they compare the actual decoded values correctly.
Frequently Asked Questions
What is a JSON diff?
A JSON diff is the set of differences between two JSON objects. It identifies which keys were added, removed, or changed, including changes nested deep inside objects and arrays. JSON diff tools automate this comparison so you don't have to read through two documents line by line.
How does JSON diffing work?
JSON diffing works by recursively walking both objects key by key. For each key, the tool checks whether it exists in both objects, only one, or both but with different values. For arrays, it compares elements by index position. The result is a list of changes categorized as added, removed, or changed.
What is the difference between a JSON diff and a text diff?
A text diff compares files line by line as plain text. A JSON diff understands the data structure — it compares keys and values semantically. Reordering keys (which doesn't change the data) won't show as a difference in a JSON diff, but would in a text diff. JSON diffs also show the exact path to each change.
Does key order matter when comparing JSON?
No. The JSON specification (RFC 8259) states that objects are unordered collections of key-value pairs. Two JSON objects with the same keys and values in different order are semantically identical. A proper JSON diff tool compares by key name, not by line position.
How are arrays compared in a JSON diff?
Arrays are compared by index position. Element 0 in the original is compared to element 0 in the modified, and so on. If one array is longer, the extra elements are reported as added or removed. Inserting an element at the beginning shifts every index, making all subsequent elements appear changed.
Can I compare large JSON files?
Yes, within your browser's memory limits. The comparison runs entirely client-side, so there is no server-imposed file size limit. For very large files (tens of megabytes), performance depends on your device. Deeply nested structures and long arrays are handled recursively.
What is JSON Patch (RFC 6902)?
JSON Patch is a standard format for describing changes to a JSON document as an array of operations. Each operation specifies an action (add, remove, replace, move, copy, test), a target path (JSON Pointer), and optionally a value. It's commonly used in REST APIs with the PATCH HTTP method.
What is JSON Merge Patch (RFC 7396)?
JSON Merge Patch is a simpler alternative to JSON Patch. You send a partial JSON object containing only the fields to change. Fields set to null are removed. It's easier to read and write but cannot express array modifications, moves, or copies.
When would I need to diff JSON objects?
Common use cases include: debugging API responses (comparing expected vs. actual output), reviewing configuration changes, comparing database records across environments, validating data transformations in ETL pipelines, and auditing changes in version-controlled JSON files.
Does this tool store my data?
No. All processing happens entirely in your browser using JavaScript. Your JSON data is never sent to any server. You can verify this by disconnecting from the internet or checking network requests in your browser's developer tools.
Related Tools
- JSON Formatter — format and beautify JSON for readability
- JSON Validator — check whether JSON is syntactically valid
- JSON to CSV Converter — convert JSON arrays to CSV format
- JSON to XML Converter — transform JSON into XML
- Text Diff Tool — compare any two text blocks line by line
- How to Compare JSON Objects — complete guide to JSON diffing methods and tools
Privacy & Limitations
- Client-side only. No data is sent to any server. No cookies, no tracking of JSON entered.
- Index-based array comparison. Arrays are compared by position, not by content matching. Inserting an element at the start will cascade changes through every subsequent index. For order-independent array comparison, sort arrays before diffing.
- No merge or patch output. This tool shows differences visually but does not generate JSON Patch (RFC 6902) or Merge Patch (RFC 7396) documents.
- Browser memory limits. Very large JSON files (50 MB+) may cause slowdowns depending on your device and browser.
Related Tools
View all toolsBig-O Notation Visualizer
Interactive plot of O(1) through O(n!) complexity curves with operation count comparison
JSON Formatter
Format and beautify JSON with proper indentation
JSON Validator
Validate JSON syntax and show errors
CSV to JSON Converter
Convert CSV data to JSON format with auto-detection
JSON to CSV Converter
Convert JSON arrays to CSV format with nested object handling
JWT Decoder
Decode JWT tokens and display header and payload
JSON Diff Viewer FAQ
What is a JSON diff?
A JSON diff is the set of differences between two JSON objects. It identifies which keys were added, removed, or changed, including changes nested deep inside objects and arrays. JSON diff tools automate this comparison so you don't have to read through two files line by line.
How does JSON diffing work?
JSON diffing works by recursively walking both objects key by key. For each key, the tool checks whether it exists in both objects, only one, or both but with different values. For arrays, it compares elements by index position. The result is a list of changes categorized as added, removed, or changed.
What is the difference between a JSON diff and a text diff?
A text diff compares files line by line as plain text. A JSON diff understands the data structure — it compares keys and values semantically. This means reordering keys (which doesn't change the data) won't show as a difference in a JSON diff, but would in a text diff. JSON diffs also show the exact path to each change (e.g., 'address.city').
Does key order matter when comparing JSON?
No. The JSON specification states that objects are unordered collections of key-value pairs. Two JSON objects with the same keys and values in different order are semantically identical. A proper JSON diff tool compares by key name, not by position, so reordering keys produces no differences.
How are arrays compared in a JSON diff?
Arrays are compared by index position. The element at index 0 in the original is compared to index 0 in the modified, index 1 to index 1, and so on. If one array is longer, the extra elements are reported as added or removed. This means inserting an element at the beginning will show every subsequent element as changed.
Can I compare large JSON files with this tool?
Yes, within the limits of your browser's memory. The comparison runs entirely in your browser using JavaScript, so there is no server-side file size limit. For very large files (tens of megabytes), performance depends on your device. The tool handles deeply nested structures and long arrays.
What is JSON Patch (RFC 6902)?
JSON Patch is a standard format (RFC 6902) for describing changes to a JSON document. It uses an array of operation objects with 'op' (add, remove, replace, move, copy, test), 'path' (JSON Pointer to the target location), and 'value' fields. It's used in APIs to send partial updates instead of full replacements.
What is JSON Merge Patch (RFC 7396)?
JSON Merge Patch is a simpler alternative to JSON Patch. You send a partial JSON object containing only the fields you want to change. Fields set to null are removed. It's easier to read and write than JSON Patch but cannot express some operations like array element insertion or reordering.
When would I need to diff JSON objects?
Common use cases include: debugging API responses (comparing expected vs. actual output), reviewing configuration changes before deployment, comparing database records across environments, validating data transformations in ETL pipelines, and auditing changes in version-controlled JSON files.
Does this JSON diff tool store my data?
No. All processing happens entirely in your browser using JavaScript. Your JSON data is never sent to any server. You can verify this by using the tool offline after the page loads or by inspecting network requests in your browser's developer tools.