πŸ”€

JSON Diff & Patch Comparer

Compare two JSON documents side by side with a visual line-by-line diff. Additions appear in green, deletions in red, and modifications in yellow. Generate an RFC 6902 JSON Patch payload for the detected changes.

JSON Diff & Patch Comparer

Compare two JSON documents side by side. Additions in green, deletions in red, modifications in yellow.

How to Use the JSON Diff and Patch Comparer

A backend developer pushes a refactoring commit that changes the structure of a REST API response. The mobile app team reports broken screens after pulling the update. Open this tool, paste the old API response schema into the Original panel, paste the new schema into the Modified panel, and click Compare. The Side by Side view highlights every added field in green, removed field in red, and modified value in yellow. Switch to JSON Patch view to get a standard RFC 6902 patch document that the mobile team can apply to handle both old and new formats during the transition period.

DevOps troubleshooting config drift

A DevOps engineer suspects that a production Kubernetes ConfigMap has drifted from the version in Git. Export the current ConfigMap as JSON, paste it alongside the Git version, and click Compare. The Unified view shows every changed value as a scrollable diff stream, making it easy to spot the one environment variable that was manually changed in production without going through the deployment pipeline.

Data migration validation

A data engineer migrates MongoDB documents from one schema to another and needs to verify that the transformation logic is correct. Paste a sample original document and its transformed version, then click Compare. The tool detects nested field additions, removals, and value changes at any depth. The stats row shows the exact count of each operation type, confirming whether the migration script added, removed, or modified the expected fields.

API contract review

A product manager reviews two versions of an API contract before approving a breaking change. Paste the current and proposed response schemas, click Compare, and review the JSON Patch output. Each operation in the patch array describes exactly what changes, allowing the team to discuss whether each modification is backward-compatible or requires a version bump.

Testing expected API responses

A QA engineer validates that an API response matches the expected schema by diffing the actual response against the expected template. Paste both JSON documents, click Compare, and verify that the stats row shows zero differences. If there are unexpected changes, the Unified view pinpoints exactly which fields deviate from the expected structure.

How the JSON Diff Engine Works

The tool needs to tell you exactly what changed between two JSON documents without you manually comparing them line by line. It does this by building a recursive tree walk of both documents simultaneously, comparing every value at every level of nesting. For each difference found, it generates a structured operation object that describes what happened.

Comparing Keys and Values at Every Level

For each object node, the algorithm collects every key that appears in either the source or the target. A key present only in the source becomes a remove operation. A key present only in the target becomes an add operation. A key present in both but with different values either recurses deeper (if both values are objects) or records a replace operation for primitive mismatches. This means a change to a nested field like data.users[0].address.city is detected and reported with its exact path.

Array Comparison and Index Tracking

Arrays are compared element by element using index positions rather than value identity. If two arrays contain the same elements in a different order, the tool reports removals at the original indices and additions at the new indices rather than claiming the values were modified. This matters because the RFC 6902 JSON Patch format operates on array indices, so the patch output must reflect where elements actually sit in each array. The stats row shows the exact count of each operation type, giving you a quick summary of how much changed between the two documents.

Frequently Asked Questions

What is the JSON Patch format used for?

RFC 6902 JSON Patch is a standard format for describing changes between two JSON documents as a list of operations. Instead of sending an entire 200-line configuration document over HTTP PATCH, a client can send a 3-line patch that says "change this one field." Libraries like fast-json-patch in JavaScript and json-patch in Python can apply these operations to transform the original document into the target.

Why does reordering array elements show as add and remove instead of modify?

JSON Patch identifies array elements by their index position, not by their value. If you move an item from index 0 to index 2, the patch cannot say "move element" because the RFC 6902 move operation only works within a single document. Instead, the tool correctly reports a removal at index 0 and an addition at index 2, which is how any RFC 6902-compliant library would interpret the change.

How deeply can it compare nested objects?

There is no depth limit. The algorithm recursively walks every level of both JSON trees. A change at path /data/users/0/address/city is detected and reported just as accurately as a change at the root level. The JSON Pointer paths in the patch output make it easy to locate exactly where each change occurred, even in deeply nested structures.

Can I use the patch output in production code?

Yes. The patch array is valid RFC 6902 JSON and works with any compliant library. In a Node.js API, you can apply it with fast-json-patch.applyPatch(). In Python, use jsonpatch.JsonPatch.from_string(). The output is a plain JSON array that serialises directly into an HTTP PATCH request body with content type application/json-patch+json.

What happens when both documents are identical?

The tool displays "No differences found" in all three views. The stats row shows zero adds, zero removals, and zero modifications. The JSON Patch output is an empty array, which means applying it to the source document produces no changes β€” confirming the two documents are equivalent.

jsondiffpatchcomparemergerfc6902

More Tools You Might Like

πŸ”·JSON to TypeScript Generator
πŸ”€Git Command Flow Builder
πŸ“‹CSV to JSON & XML Data Converter
βœ…JSON Payload Schema Validator
πŸ”“JSON String Un-escaper
✨JSON Prettifier