View:
Indent:
Original JSON0 B
Ready
Modified JSON0 B
Ready
Diff Result

Diff will appear here

Paste two JSON documents above and click Compare. The diff will show added, removed, and changed lines.

Features

Three diff views in one tool

📝 Line diff

Classic git-style diff: green for added, red for removed. Compares pretty-printed JSON line by line using LCS algorithm.

🏗️ Structural diff

Semantic comparison by JSON path. Shows user.name: "A" → "B" instead of just changed lines. Understands object structure.

📋 JSON Patch

Generate RFC 6902 JSON Patch operations (add, remove, replace, move, copy, test). Apply patches with the JSON Patch tool.

📊 Summary stats

See the count of added, removed, and changed paths at a glance. Quickly assess the scope of changes.

🔀 Swap inputs

One-click swap button flips original and modified. Useful for reverse-diffing or comparing from different perspectives.

💾 Auto-save

Both inputs are saved to localStorage. Come back later and resume your comparison.

FAQ

Comparing JSON — common questions

How do I compare two JSON files?

Paste your first JSON in the left input ("Original JSON") and the second JSON in the right input ("Modified JSON"). The diff appears automatically in the bottom panel as you type (with a small debounce for performance). You can also click the Compare button or use the upload buttons to load files from disk.

Use the View dropdown to switch between line diff (git-style), structural diff (path-based), and JSON Patch (RFC 6902 operations).

What's the difference between line diff and structural diff?

Line diff compares the formatted JSON text line-by-line, similar to git diff. It's intuitive for humans — you see exactly which lines changed. However, it can be confused by reordering: if you move a key from position 1 to position 5 in an object, line diff will show that key as removed and re-added.

Structural diff compares the JSON values semantically. It walks both trees in parallel and reports changes by JSON path: user.name changed from "A" to "B", items[2] was added, etc. This is more accurate for objects (where key order doesn't matter semantically) and produces cleaner diffs for reordered content.

Use line diff for visual inspection and code reviews. Use structural diff for programmatic change detection.

What is JSON Patch?

JSON Patch (RFC 6902) is a standard format for describing changes to a JSON document. A patch is an array of operations, each with an op (add, remove, replace, move, copy, or test), a path (JSON Pointer), and a value.

For example: [{"op":"replace","path":"/user/name","value":"Ada"}] replaces user.name with "Ada". Patches are commonly used in APIs (e.g., HTTP PATCH method) for partial updates.

JSONLab can generate patches from a diff, and the JSON Patch tool can apply patches to a base document.

How are arrays diffed?

Arrays are compared element-by-element by index. If array A has 3 items and array B has 5, the extra items in B are shown as added. If item at index 1 differs between A and B, that's shown as a change at path [1].

This index-based comparison can produce noisy diffs for arrays where items have been inserted or removed in the middle. For such cases, consider using a stable ID field and diffing by ID instead — JSONLab doesn't do this automatically.

Is there a size limit?

No artificial limit. The diff engine uses an efficient LCS algorithm with O(n*m) time and space complexity for line diff. For very large JSON files (>10MB), the diff may take a few seconds but will complete. The structural diff is more efficient (linear in the number of nodes).