Ttooleras
🔍

JSON Diff

JSON Tools

Compare two JSON objects — find added, removed, and changed properties. Free, private — all processing in your browser.

11
Advertisement

The JSON Diff tool compares two JSON objects or arrays and highlights exactly what is different: properties that were added, properties that were removed, and properties whose values changed. Works on any depth of nesting (objects within objects within arrays within objects) and handles both key-level changes and value-level changes. Results are shown in a clear side-by-side view with color-coded highlighting (green for additions, red for deletions, yellow for modifications) plus a structured change list in JSON Patch format (RFC 6902) that you can apply programmatically.

Comparing JSON is essential in several workflows: API contract testing (did the response shape change?), config file reviews (what changed between versions?), snapshot testing (Jest, Vitest snapshot diffing), debugging API regressions (staging response vs production), and data migration verification (before and after an ETL run). This tool runs entirely in your browser, so you can safely compare JSON containing sensitive data — API responses with tokens, customer data, internal configs — without uploading anything. Supports order-sensitive and order-insensitive array comparison, optional ignore lists (skip volatile fields like timestamps), and can generate minimal JSON Patch documents.

JSON Diff — key features

Visual side-by-side diff

Two panels with synced scrolling. Added, removed, and modified properties color-coded. Click to jump between differences.

Deep nested comparison

Recursively compares objects within objects within arrays. Shows precise path to each difference (JSON Pointer).

JSON Patch output

Produces standard RFC 6902 JSON Patch document — the difference as a sequence of operations you can apply to transform JSON 1 into JSON 2.

Array comparison modes

Order-sensitive or order-insensitive. Also supports key-based array matching (e.g., match objects by id field).

Ignore list

Exclude volatile fields (timestamps, request IDs) from the diff. Specify paths to skip.

Type-aware

Distinguishes string from number, null from missing, etc. Type changes are highlighted as modifications.

Change statistics

Count of added, removed, modified properties. Depth of deepest change. Total change score.

100% client-side

Both JSON objects compared entirely in your browser. Safe for sensitive API responses, internal configs, customer data.

How to use the JSON Diff

  1. 1

    Paste two JSON documents

    First JSON on the left, second JSON on the right. Can be objects, arrays, or primitives.

  2. 2

    Choose comparison mode

    Order-sensitive (default, strict) or order-insensitive (treats arrays as sets). Enable key-based array matching for object arrays.

  3. 3

    (Optional) Set ignore paths

    Specify JSON Pointer paths to skip (e.g., /timestamp, /session_id) if you want to ignore volatile fields.

  4. 4

    Review the diff

    Side-by-side view highlights differences. Added = green, removed = red, modified = yellow. Click any difference to see details.

  5. 5

    View JSON Patch

    Switch to Patch view to see the RFC 6902 Patch document — apply it programmatically to transform JSON 1 into JSON 2.

  6. 6

    Copy or export

    Copy the Patch document or download the diff as JSON or a plain-text report.

Common use cases for the JSON Diff

API development

  • API response regression testing: Save a known-good response as baseline. Compare every new response against baseline to catch accidental breaking changes.
  • Contract testing: Between microservices, compare actual API responses against schema examples. Differences reveal contract violations.
  • Version comparison: API v1 vs API v2 response — see exactly what changed. Useful for migration documentation.
  • Production vs staging: Same request to different environments — differences reveal environment drift or bugs.

Configuration management

  • Config file review: Compare current config with previous version. Catch unintended changes before deployment.
  • Environment parity: Compare dev, staging, and production configs. Differences reveal environment drift.
  • Tenant configuration: Compare tenant-specific configs to identify shared settings vs differences.
  • Feature flag changes: Compare feature flag snapshots over time. Audit what changed and when.

Testing

  • Snapshot testing: Jest or Vitest snapshots compare objects — this tool shows exactly why a snapshot failed.
  • Integration test verification: Expected vs actual test results in JSON — diff reveals test failures.
  • Data migration verification: Compare pre-migration and post-migration JSON to verify transformation correctness.
  • Database export comparison: Compare JSON dumps to identify data changes between time points.

Debugging

  • Debug unexpected API changes: Paste working response and broken response — tool shows exactly what changed.
  • Third-party API updates: External APIs sometimes change without notice. Diff their responses to detect silent breaking changes.
  • Investigate webhook inconsistencies: Compare two similar webhook payloads to find subtle differences.
  • Compare AI/LLM outputs: Different model versions may return slightly different JSON — diff to see exactly what shifted.

JSON Diff — examples

Simple object diff

Basic property comparison.

Input
A: {"name":"Alice","age":30}
B: {"name":"Alice","age":31,"city":"NYC"}
Output
Modified: /age (30 to 31)
Added: /city (value: NYC)

Nested object diff

Deep property change.

Input
A: {"user":{"profile":{"email":"a@x.com"}}}
B: {"user":{"profile":{"email":"b@x.com"}}}
Output
Modified: /user/profile/email
From: a@x.com
To: b@x.com

Array insertion

New item in array.

Input
A: [{"id":1},{"id":2}]
B: [{"id":1},{"id":3},{"id":2}]
Output
Added at index 1: {id: 3}
(Array grew from 2 items to 3 items)

JSON Patch output

Standard RFC 6902 patch.

Input
Base: {"name":"Alice","age":30}
Target: {"name":"Alice","age":31,"city":"NYC"}
Output
[
  {"op":"replace","path":"/age","value":31},
  {"op":"add","path":"/city","value":"NYC"}
]

Ignore timestamps

Skip volatile fields.

Input
A: {"data":[1,2,3],"timestamp":1714521600}
B: {"data":[1,2,3],"timestamp":1714521605}
Ignore: /timestamp
Output
No differences (timestamp ignored)

Type change detection

Number vs string.

Input
A: {"count":5}
B: {"count":"5"}
Output
Modified: /count (type changed: number to string)

Technical details

JSON diff is more nuanced than text diff. Two JSON strings can differ in whitespace but represent the same data (semantically equal), or differ in property order but have identical content. A proper JSON diff compares structure, not text.

Diff algorithms:

1. Naive object diff — recursively compare every key and value. Simple but fails on arrays (is item at index 2 moved, or replaced?).
2. JSON Patch (RFC 6902) — produces a sequence of operations (add, remove, replace, move, copy, test) that transform one JSON into another. Standard, machine-applicable format.
3. Myers-style diff — used for arrays, identifies longest common subsequence. Handles reordering and insertions.

Change types:

- Added: property exists in the second JSON but not the first.
- Removed: property exists in the first but not the second.
- Modified: property exists in both but values differ.
- Unchanged: property exists in both with the same value (usually hidden in diff view).

Array comparison modes:

- Order-sensitive: [1, 2, 3] and [1, 3, 2] are different (2 and 3 changed).
- Order-insensitive: [1, 2, 3] and [1, 3, 2] are the same (as a set).
- Default is order-sensitive (array order usually matters).

Nested object handling:

Objects within objects are recursed. The diff shows the deepest level where values differ, giving you a precise location (via JSON Pointer, RFC 6901) like /user/address/street.

Type handling:

{ "count": 5 } vs { "count": "5" } — number vs string. The diff treats these as different (type matters). Value equality uses JavaScript strict equality with type coercion disabled.

Volatile field ignoring:

Use-case: API responses include timestamp, request_id, session_id that change every request but do not indicate a real difference. Tool allows an ignore list (JSON Pointer paths to exclude from diff).

JSON Patch output example:

First:
``json
{ "name": "Alice", "age": 30 }
``

Second:
``json
{ "name": "Alice", "age": 31, "city": "NYC" }
``

JSON Patch:
``json
[
{ "op": "replace", "path": "/age", "value": 31 },
{ "op": "add", "path": "/city", "value": "NYC" }
]
``

Performance:

Structural diff is O(n) where n is the number of properties. Very large JSON (1 MB+) may be slow to diff visually but fast to diff programmatically. For performance-critical comparison, use a hash-based diff (compute SHA-256 of each subtree, diff hashes).

Common problems and solutions

Array order sensitivity surprise

Default comparison is order-sensitive. [1,2,3] and [1,3,2] will show 2 differences. If order does not matter (e.g., tag lists), enable order-insensitive mode.

Whitespace differences

JSON is semantically whitespace-insensitive. Pretty-printed and minified versions are identical to this tool. But if you need text diff, use the Text Diff Checker tool.

Volatile fields create false positives

Timestamps, request IDs, session IDs change constantly. Use the ignore list to exclude these from comparison. Or normalize both inputs before comparing.

Large arrays cause confusing diffs

If two large arrays have multiple differences, the default diff may show many unrelated changes. Use key-based array matching (match objects by id field) for clearer results.

Number precision loss

Large integers ( over 2^53) lose precision when parsed as JavaScript numbers. 9007199254740993 becomes 9007199254740992. Two JSON values that look identical may differ after parsing. Use BigInt libraries or string-based JSON for financial data.

Null vs missing vs undefined

{a: null} and {} are different — one has key a with null value, one has no key. The diff distinguishes these. Some frameworks serialize both the same way — be aware of the distinction.

Unicode normalization

Same visible string can have different Unicode representations (e.g., combined vs decomposed é). Two JSON strings that look identical may differ at byte level. Normalize before comparing if this matters.

Slow on very large JSON

Diffing multi-MB JSON can take several seconds. For huge data, consider hash-based comparison (compare subtree hashes) or stream-based diff tools.

JSON Diff — comparisons and alternatives

JSON Diff vs Text Diff: Text diff compares strings character-by-character. JSON diff compares structure — semantic equality ignoring whitespace and property order. Use text diff for source code; JSON diff for data.

JSON Patch (RFC 6902) vs JSON Merge Patch (RFC 7396): JSON Patch produces minimal operations (add, remove, replace). JSON Merge Patch produces a document showing the merged result. Use Patch for efficient incremental updates; Merge Patch for simpler state updates.

Semantic vs Syntactic diff: Semantic diff ignores whitespace, property order, and cosmetic differences — focuses on data equality. Syntactic diff cares about text. This tool is semantic by default.

Visual diff vs API Patch: Visual diff for human review. JSON Patch for programmatic application (transform JSON 1 into JSON 2 via API call).

This tool vs command-line diff (jq, diff): CLI tools handle huge files better and integrate into shell pipelines. This tool handles interactive human review with visual feedback. Use both — they complement each other.

JSON Diff vs Git diff: Git diff is line-based and works on any text. JSON Diff understands structure. For JSON in Git, both are useful — git diff for version control, JSON diff for structural changes.

Frequently asked questions about the JSON Diff

What is JSON Diff?

A tool that compares two JSON objects or arrays and shows exactly what is different — which properties were added, removed, or changed. Goes beyond simple text comparison by understanding JSON structure — ignoring whitespace and optional ordering, focusing on data equality.

How is JSON Diff different from text diff?

Text diff compares character by character — whitespace matters, property order matters, formatting matters. JSON Diff compares structure — ignores whitespace, optional key ordering, and cosmetic differences. Two JSON files that look different as text can be identical as JSON.

What is JSON Patch?

JSON Patch (RFC 6902) is a standard format for describing changes to JSON documents. It lists operations (add, remove, replace, move, copy) that transform one JSON into another. The diff tool can output JSON Patch — use it to apply changes programmatically.

How does array comparison work?

By default, order-sensitive: items at different positions are treated as different. Switch to order-insensitive for set-like comparison (tag lists, permissions). For arrays of objects with stable IDs, use key-based matching (match by id field).

Can I ignore certain fields?

Yes. Add JSON Pointer paths to the ignore list (e.g., /timestamp, /request_id). Those paths are skipped during comparison — useful for API testing where timestamps shift every request.

Is my JSON safe to paste?

Yes. Both JSON inputs are compared entirely in your browser. No server involvement. Safe for sensitive API responses, internal configs, customer data. Open DevTools Network tab to verify.

What are the color codes?

Green = added (exists in second but not first). Red = removed (exists in first but not second). Yellow = modified (exists in both but different values). Gray = unchanged (shown optionally for context).

Can I compare nested objects?

Yes, at any depth. The diff recurses into nested objects and arrays, showing the precise location of every difference using JSON Pointer syntax (e.g., /user/profile/address/street).

How do I apply the diff to transform one JSON into another?

Use the JSON Patch output. It is an RFC 6902 document that can be applied programmatically with any JSON Patch library (fast-json-patch in JavaScript, python-json-patch in Python). Applying the patch to the first JSON produces the second.

Can I compare two arrays?

Yes. Both object-level and array-level comparison work. For arrays of primitives (numbers, strings), order-sensitive and order-insensitive modes both available. For arrays of objects, consider key-based matching.

Additional resources

Advertisement

Related tools

All JSON Tools

Learn more

Explore more tools

200+ free tools that run in your browser.

Browse all tools →