JSON Patch Builder (RFC 6902)
Apply a JSON Patch (RFC 6902) — the operation-based patch format with add, remove, replace, move, copy, test. More expressive than merge patch (can describe array element changes), but more verbose. Also includes a "diff" mode that computes the patch needed to transform one JSON document into another.
How to use the JSON Patch Builder (RFC 6902)
Apply mode: paste the original document and a patch (array of operation objects), get the result. Diff mode: paste two documents, get the patch that transforms A into B. The diff is "shallow" — it uses replace operations for objects rather than computing the minimal patch, but the result applies correctly.
Applying and building a JSON Patch
Sometimes you do not want to send a whole document — you want to describe the change. RFC 6902 JSON Patch does exactly that: an ordered list of operations (add, remove, replace, move, copy, test) that transforms one document into another. It is more verbose than a merge patch but far more precise, because it can target individual array elements and assert preconditions.
This applies a patch to a document and, in diff mode, computes the patch that turns one document into another. Use it when the operations themselves matter — an audit trail, an undo stack, a PATCH request body. When you simply want to combine two objects into one merged result, the JSON merge tool is the simpler fit.
Common use cases
- Build a PATCH body — produce the RFC 6902 ops an API expects.
- Diff two documents — compute the patch that transforms one into the other.
- Audit changes — record edits as an explicit list of operations.
- Target array elements — describe changes a merge patch cannot express.
- Apply and verify — run a patch against a document and check the result.