Compare two JSON documents
online, free & instant
Paste two JSON objects side-by-side and instantly see every added, removed, and changed field — identified by path. No signup, no server.
Open JSON Diff ToolStructural diff — not a line-by-line text diff
Unlike a text diff that compares raw lines, the JSON diff tool parses both documents into their AST and compares them structurally. Field order doesn't matter — only the actual data does.
user.address.city) so you know exactly where to look.
No account. No upload. No nonsense.
No Server
Your JSON never leaves your device. Both documents are compared locally in the browser.
Zero Dependencies
Single self-contained HTML file. No libraries, no CDN calls, nothing to break.
Works Offline
Load once and diff JSON forever — even without an internet connection.
Related JSON tools
Common questions answered
Is the JSON diff tool free?
Yes, completely free with no signup.
How does JSON diff compare documents?
It parses both JSON documents, then recursively compares them by key path, showing added, removed, and changed fields.
Does JSON diff work offline?
Yes, all comparison is done locally in your browser.
Can JSON diff handle large files?
Yes, it handles large documents efficiently.
Does JSON diff show nested changes?
Yes, it shows changes at every level of nesting with the full JSONPath for each difference.
What is JSON diffing?
JSON diffing compares two documents and identifies every difference — added fields, removed fields, changed values, and reordered elements. Unlike text-based diff tools that compare lines, a JSON diff understands structure: it knows that {"a":1,"b":2} and {"b":2,"a":1} are semantically identical even though the text differs.
This tool performs a deep structural comparison, walking both trees in parallel. Differences are color-coded: green for additions, red for removals, yellow for value changes. Each difference includes the JSON path and old/new values, making it easy to understand exactly what changed.
// Left
{"name":"Alice","age":30,
"city":"Portland"}
// Right
{"name":"Alice","age":31,
"role":"admin"}
name: "Alice" (same) ~ age: 30 → 31 (changed) - city: "Portland" (removed) + role: "admin" (added)
Get the most out of this tool
- Use JSON diff to verify API changes between versions — structural diff catches field additions text diff misses.
- Sort keys before diffing to focus on value changes rather than key order differences.
- Compare configuration files across environments (dev/staging/prod) to find settings that have diverged.
Understanding JSON diffing
JSON diffing is the process of computing the semantic difference between two JSON documents. Unlike a plain text diff (which compares line by line), a semantic JSON diff understands the structure: adding an element to an array is one change, not two lines changed. Renaming a key while keeping its value should show as a deletion and an addition at the key level, not as a changed value. This structural awareness makes JSON diffs far more useful for understanding what actually changed in your data.
There are several JSON diff algorithms in use. The RFC 6902 JSON Patch format represents diffs as a list of operations — "add", "remove", "replace", "move", "copy", "test" — applied to specific JSON Pointer paths. This is the most widely used format because it can be applied programmatically to transform the original document into the target. It is used by REST APIs for partial updates (PATCH requests) and by version control systems for structured data.
Object comparison is straightforward: match keys by name, then recursively compare values. A key present in the left document but absent in the right is a deletion. A key in the right but not the left is an addition. A key present in both with different values is a change, and the tool recurses into nested objects to show exactly which nested field changed. This produces a precise, minimal diff rather than marking the entire parent object as changed.
Array comparison is the hardest part of JSON diffing. Arrays are ordered sequences, not maps — there are no keys to match on. The optimal algorithm for array diffing uses the longest common subsequence (LCS) algorithm, the same algorithm used by Git's text diff. This minimizes the number of shown changes by finding the longest sequence of elements that appears in both arrays in the same order, then marking everything else as additions or removals.
Key sorting before diffing is important for clean results. If two JSON objects have the same keys and values but in a different order, a structural diff correctly reports no changes (since JSON object key order is semantically meaningless). However, if you diff minified JSON from two versions without sorting keys first, you may see spurious diffs. This tool sorts keys internally for comparison, ensuring that only meaningful changes appear in the output.
JSON diff is widely used in API versioning workflows. When an API provider releases a new version, teams compare the JSON Schema or sample response from the old version against the new version to understand breaking changes — fields that were removed, type changes, new required fields. This automation replaces manual reading of migration guides and catches undocumented changes before they break integrations.
When developers use this tool
Additional frequently asked questions
Does the diff detect moved keys or only additions and deletions?
The tool detects additions, deletions, and value changes at every nesting level. For arrays, it uses a sequence-matching algorithm to distinguish moved elements from additions and deletions. Key renames in objects appear as a deletion of the old key and an addition of the new key, since JSON does not have a native "rename" concept.
Does key order affect the diff result?
No. JSON object key order is semantically meaningless per the specification. The diff tool normalizes key order before comparing, so two objects with identical keys and values in different orders show zero differences — which is the correct result.
Can I use the diff output to patch a document programmatically?
Yes, through the API. The api.jsonfmt.dev/diff endpoint returns RFC 6902 JSON Patch format, which is a list of operations that transforms the original document into the target. You can apply these operations using any JSON Patch library in your language of choice.
How does the tool handle arrays of objects?
Arrays of objects are compared element by element using sequence matching. If an object in the left array matches an object in the right array on a key field (like "id"), the tool treats them as the same item and shows only the field-level changes within it, rather than marking the whole item as removed and a new one added.