JSON Diff Online

Compare two JSON documents structurally and get a JSON Patch (RFC 6902) and Merge Patch (RFC 7386); apply patches to a document.

Free tool: 20 requests per minute.

Result

Press “Run” to see the result.

The JSON diff API compares two JSON values by structure, not by text: key order and formatting do not matter. action=diff (with a and b) returns whether they are equal, a summary of added, removed and replaced values, an RFC 6902 JSON Patch that turns a into b and the equivalent RFC 7386 Merge Patch, the format used by many REST APIs for PATCH requests.

action=patch applies a JSON Patch (add, remove, replace, move, copy, test) to a document and returns the result; a failing test or a missing path returns 422 with the index of the operation, so patches can be validated before they reach your database. action=merge applies a Merge Patch (null removes a key).

Arrays are compared after removing their common beginning and end, so appending or removing items produces short patches. Paths use JSON Pointer with ~0 / ~1 escaping.

Use this in your code

curl -X POST "https://apibox.io.vn/v1/json-diff" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a":{"name":"A","tags":["x"],"n":{"a":1,"b":2}},"b":{"name":"B","tags":["x","y"],"n":{"a":1}}}'

API documentation → Get a free API key

FAQ

JSON Patch or Merge Patch?

JSON Patch is a list of precise operations (including array positions and tests). Merge Patch is a partial document: simpler, but it cannot set a value to null or change part of an array.

Does key order matter?

No. {"a":1,"b":2} equals {"b":2,"a":1}. Array order does matter.

What happens when a patch fails?

Nothing is applied; you get HTTP 422 with code patch_failed and the index of the failing operation.