JSON Patch Builder (RFC 6902)
Generate an RFC 6902 JSON Patch from a source/target pair, or apply an existing patch to a document. Supports add, remove, replace, move, copy, test ops.
[
{
"op": "replace",
"path": "/age",
"value": 31
},
{
"op": "replace",
"path": "/address/city",
"value": "Busan"
},
{
"op": "remove",
"path": "/address/zip"
},
{
"op": "add",
"path": "/address/country",
"value": "KR"
},
{
"op": "replace",
"path": "/tags/1",
"value": "owner"
},
{
"op": "add",
"path": "/tags/2",
"value": "user"
}
]Plain RFC 6902: the add, remove, replace, move, copy and test operations, with JSON Pointer escaping (~0 for ~, ~1 for /).
How to use
- Diff mode: paste source and target, see the patch JSON. Edit either side to see how the patch changes.
- Apply mode: paste source and a patch array, see the resulting document. Errors (bad pointer, failed
test) show inline. - JSON Pointer syntax:
/foo/0/barwalksfoo.0.bar. Escape/as~1,~as~0. Trailing-in an array path means 'append'.
About this tool
ShowHide
RFC 6902 JSON Patch is a wire format for describing changes to a JSON document — useful for PATCH requests, optimistic updates, undo history, and operational transforms. This tool does both directions: paste a source and target JSON, get the minimal patch that converts one to the other; or paste a source and a patch, see the result after applying. The diff uses recursive structural comparison with ~0/~1 JSON Pointer escaping for keys with slashes or tildes. The apply side honors all six ops including test (assertion fails throw an error), copy, and move. Useful for testing patches before hitting your server, or working out the right ops by example.
Frequently asked questions
Why not just send the new document?
Bandwidth for one. Concurrency for two: if Alice and Bob both edit a doc, you can merge their patches semantically (replace /name is compatible with add /tags/-), while two full docs would have to pick a winner. Plus, patches are a precise audit trail of what changed and when.
Is this the same as JSON Merge Patch (RFC 7396)?
No. Merge Patch is simpler — you send a partial document where present keys overwrite and null deletes. It's easier for humans but loses precision (can't add to an array, can't represent literal null values, no atomic test). RFC 6902 (this tool) is the precise wire format. RFC 7396 is the convenience format.
How does a patch keep two people from overwriting each other?
Through the test operation, which is the reason it exists. Prefixing a change with a test on the value you expect makes the whole patch fail if someone else has already modified that field, so you learn about the conflict instead of quietly winning. Without a test, a patch is just as capable of clobbering a concurrent edit as sending the whole document.
When is a diff-generated patch the wrong thing to send?
When the two documents differ in ways that are meaningless to your data. A generated patch works on structure, so a reordered array of objects can come out as a long list of replacements rather than a move, and an object whose keys were serialised in a different order can produce noise. Send an intentional patch — the operations you meant — when the receiving system logs or audits what changed.
Related tools
Patch / Diff Inspector
Read a unified diff or .patch file: files touched, insertions and deletions per file, and the malformed hunks that make git apply fail.
Developer
JSON Pointer Resolver (RFC 6901)
Resolve an RFC 6901 JSON Pointer like /user/roles/0 against a document — with ~0/~1 escaping, URI fragments, and a clickable list of every pointer.
Developer
JSON Merge Patch (RFC 7386)
Apply or generate an RFC 7386 JSON merge patch, with every change listed — including the null that deletes a key rather than setting one.
Developer
JSON Schema Validator
Check a JSON document against a JSON Schema in your browser. Every error gets its JSON Pointer, the line it lands on, and the keyword that failed.
Developer
JSON Diff
Compare two JSON documents structurally — see exactly which keys were added, removed, or changed.
Developer
JSON Canonicalize (RFC 8785 JCS)
Canonicalize JSON per RFC 8785 and hash it: UTF-16 key order, ECMAScript number form, no whitespace, with a SHA-256 of the exact bytes.
Developer