All tools

JSON Patch (RFC 6902) Diff & Applier

JSON

Diff two JSON documents into an RFC 6902 JSON Patch operation list, or apply a JSON Patch to a target document

JSON Patch (RFC 6902) describes a change to a JSON document as an explicit list of operations: add, remove, replace, move, copy, and test, each addressed by a JSON Pointer path. It is the format behind PATCH endpoints that need to express precise edits, including inserting into the middle of an array, something its simpler cousin JSON Merge Patch cannot do. This tool covers both directions. In diff mode it compares two documents you paste in and generates the patch that turns the first into the second, comparing arrays position by position rather than computing a true minimal edit distance. In apply mode it runs a patch you provide against a target document and shows the result, or tells you exactly which operation failed and why.

jsonpatchrfc6902diffjsonpatch

How to use JSON Patch (RFC 6902) Diff & Applier

  • 1.Switch to Diff mode, paste a source and a target JSON document, and copy the generated RFC 6902 patch.
  • 2.Switch to Apply mode, paste a target document and a patch operation array, and read the patched result below.
  • 3.If a patch operation fails (a missing path, a failed test, an out-of-bounds array index), the error names the operation's index and the reason.

Frequently asked questions

How is this different from JSON Merge Patch?
Merge Patch is a document shaped like the target where each key overwrites or (with a null value) deletes the matching key, and it cannot address individual array elements. JSON Patch is an explicit operation list with its own add/remove/replace/move/copy/test verbs addressed by JSON Pointer paths, so it can insert into the middle of an array or move a value without rewriting the whole structure.
Is the generated diff a minimal edit script?
No. Arrays are compared position by position, so a value that moved from index 2 to index 5 shows up as several replace operations rather than a single move. The diff is deterministic and correct when applied, but it is not the shortest possible patch.
What happens if a test operation fails?
Apply mode stops at the first operation that fails, including a test whose value does not match, and reports that operation's index and reason rather than partially applying the rest of the patch.
Does this send my data anywhere?
No, both diffing and applying run entirely in your browser (or in your own process via the SDK/API), with nothing uploaded.

Use via API, SDK, or MCP

cURL# Free: 1,000 req/day · Pro: 10,000 req/day
curl -X POST https://api.utilix.tech/v1/tools/json-patch \
  -H "Authorization: Bearer utx_live_..." \
  -H "Content-Type: application/json" \
  -d '{"mode":"diff","a":"{\"name\":\"Bob\",\"age\":30}","b":"{\"name\":\"Bob\",\"age\":31}","target":"{\"name\":\"Bob\",\"age\":30}","patch":"[{\"op\":\"replace\",\"path\":\"/age\",\"value\":31}]"}'

Get an API key from your dashboard · Full API docs →