JSON Diff

Compare two JSON documents and highlight added, removed, and changed values. Structural deep comparison — all in your browser.

Original JSON
Modified JSON

Frequently Asked Questions

This tool performs a recursive structural diff of two JSON documents. It compares keys and values at every level of nesting: keys present in the original but not the modified are marked as deleted (red), keys in the modified but not the original are marked as added (green), and keys present in both with different values are marked as changed (yellow). Nested objects are diffed recursively.
JSON diff is used for: comparing API responses between staging and production environments to catch regressions, reviewing changes to configuration files stored as JSON, debugging differences between an expected and actual test output, reviewing database schema migrations that export as JSON, and auditing changes to API response contracts between versions.
No — JSON objects are unordered by definition. This tool compares by key names, not position. {"a":1,"b":2} and {"b":2,"a":1} are considered identical. However, JSON arrays are ordered — [1,2,3] and [3,2,1] are different. Array element order is preserved and compared by position in this tool.
Arrays are compared element by element by index. If the original has 3 elements and the modified has 5, indices 0–2 are diffed normally; indices 3 and 4 are marked as added. This positional comparison is simpler than a full LCS diff but works well for most structured data comparisons. For complex array-of-objects diffing, consider using a tool like json-patch or a proper LCS algorithm.
JSON Diff (this tool) is a human-readable visualization of differences between two JSON documents. JSON Patch (RFC 6902) is a machine-readable format that describes the exact sequence of operations (add, remove, replace, move, copy, test) to transform one JSON document into another. JSON Patch is used for partial updates in REST APIs — you PATCH a resource by sending the patch document, not the full updated resource. JSON Diff visualization and JSON Patch are related concepts but serve different purposes.
Several CLI tools perform JSON diff: jq for sorting and normalizing before standard diff: diff <(jq -S . a.json) <(jq -S . b.json). The json-diff npm package: npm install -g json-diff && json-diff a.json b.json. Python's deepdiff library: python3 -c "from deepdiff import DeepDiff; import json; print(DeepDiff(json.load(open('a.json')),json.load(open('b.json'))))".
Yes. null in JSON is a distinct value. A key changing from a non-null value to null is marked as changed. A key that is absent from an object is different from a key that is present with a null value. This tool correctly distinguishes between a missing key (added/deleted) and a null-valued key (changed if it was previously a different value).
JSON Merge Patch (RFC 7396) is a simpler alternative to JSON Patch for partial updates. You send a document with only the changed keys — if a key maps to null, it is deleted; if a key is missing, it is unchanged; if a key has a value, that key is updated. For example, to update only the "age" field: PATCH /user with body {"age": 30}. It is less powerful than JSON Patch (no array operations, no move) but easier to construct programmatically.
Yes. All JSON comparison happens entirely in your browser using JavaScript — no data is sent to any server. You can use this tool safely with sensitive or proprietary JSON data, including configuration files, API credentials structures, and database exports. The tool works offline once the page is loaded.
In JavaScript, use the json-diff or deep-diff npm packages. In Python, use the deepdiff package. In PHP, implement a recursive array comparison or use a library like swaggest/json-diff. For producing RFC 6902 JSON Patch documents, use libraries like json-patch-generator (JavaScript) or php-json-patch (PHP) which output a machine-readable patch that can be applied with json-apply-patch.

About This JSON Diff Tool

This free JSON diff tool compares two JSON documents and highlights added, removed, and changed keys and values with color-coded output. Structural deep comparison runs entirely in your browser — no data is sent to any server.

When to use this tool

  • Comparing API responses between environments
  • Reviewing changes to JSON configuration files
  • Debugging differences between expected and actual test output
  • Auditing API response contract changes across versions

Related Articles

In-depth guides and technical articles.

View all →
Using JSON Diff to Detect API Breaking Changes — Schema Diff, Merge Patch, and Contract Testing
API breaking changes — removing fields, changing types, renaming keys — are detectable by diffing JSON Schema between API versions. Here's schema-level vs instance-level JSON diff, JSON Merge Patch (RFC 7396) as a simpler alternative to JSON Patch for PATCH endpoints, why array diffing requires different algorithms than object diffing, and how contract testing uses JSON diff principles to prevent breaking API deployments in CI/CD.
Why Two Identical JSON Objects Look Different in a Diff — Normalization, Canonical Form, and the Array Problem
Two JSON objects with identical data can fail equality checks because of different key ordering — a false difference that corrupts any text-level diff. Here's the three normalization problems (key ordering, formatting, numeric representation), RFC 8785 canonical JSON for digital signatures, the practical parse-sort-serialize workflow for normalization before diffing, and why arrays create a harder normalization problem with no universal solution.
JSON Structural Diff Fundamentals: Why Key Order Doesn't Matter, Null Isn't "Missing," and Arrays Can Cascade
{"a":1,"b":2} and {"b":2,"a":1} represent identical data per the JSON spec — but a text-based diff would show them as completely different. Here's how structural diffing handles key-order (unordered per spec), numeric representation differences (1 vs 1.0), the genuine structural difference between null and a missing key, and why array reordering can cascade into multiple "changes" under positional comparison.
Snapshot Testing Is Just JSON Diffing With Extra Steps — Here's Why That Explains Both Its Strengths and Its Noise
Snapshot testing is, underneath, just "save a JSON diff result and fail the test if it's not empty next time" — and seeing it this way explains both why snapshot tests catch bugs that assertion-based tests miss, and why they're notorious for generating noisy, rubber-stamped diffs. Here's how the snapshot-compare-update cycle works, why "everything changed" diffs from one intentional change lead to rubber-stamping, and why a genuine bug can hide among repetitive, expected diff entries.
JSON Patch and JSON Pointer: How "What Changed" Becomes a Standardized, Executable Sequence of Operations
"What's different between these two JSON documents" and "what's the smallest sequence of operations that transforms one into the other" are related but distinct questions — the second is what JSON Patch (RFC 6902) standardizes. Here's the six JSON Patch operations, the JSON Pointer path syntax they rely on, how the test operation enables optimistic concurrency control, and when the simpler JSON Merge Patch is sufficient instead.