JSON Patch Generator & Applier
Generate an RFC 6902 JSON Patch or an RFC 7386 Merge Patch from two documents, or apply an existing patch and see the result before you run it. Nothing is uploaded.
Fill both panes to see the result
JSON Patch vs Merge Patch
Both formats describe a change to a JSON
document, and they are not interchangeable. JSON Patch is a list of operations addressing locations by
JSON Pointer; Merge Patch is a document shaped like the target, where null means “remove
this member”.
Merge Patch cannot set a value to null
Because null already means “delete”, there is no way to say “set this
field to null”. If your API has nullable fields, Merge Patch is the wrong format. This tool
detects the case and tells you, rather than emitting a patch that quietly deletes the field.
Merge Patch replaces whole arrays
It has no way to address an array element, so changing one item means sending the entire array.
JSON Patch can target /roles/1 directly.
JSON Patch is atomic, and can assert
RFC 6902 §5 requires that a failed operation leaves the document untouched. The
test operation asserts a value before changing it, which gives you optimistic
concurrency without an ETag. Turn on Add test ops to generate them.
There is no single correct patch
For arrays in particular, several different
patches correctly transform the same source into the same target. This generator compares array elements
positionally and then trims or extends the tail. It does not try to detect that an element
moved and emit move or copy: those patches are shorter but harder to
read, and choosing between them is a heuristic, not a rule. Every patch produced here is verified to
reproduce the target exactly — tested on 30,000 randomly generated document pairs and against the
community json-patch-tests
conformance suite.
Specifications
- RFC 6902 — JavaScript Object Notation (JSON) Patch
— P. Bryan, Ed., M. Nottingham, Ed., 2013. Standards Track. Defines the six operations and the
application/json-patch+jsonmedia type. §4 Operations, §5 Error Handling. - RFC 7386 — JSON Merge Patch
— P. Hoffman, J. Snell, 2014. Standards Track. Defines the merge algorithm and the
application/merge-patch+jsonmedia type. - RFC 6901 — JSON Pointer
— P. Bryan, Ed., K. Zyp, M. Nottingham, Ed., 2013. The syntax used by every
pathandfrommember, including the~0and~1escapes. §3 Syntax. - RFC 8259 (STD 90) — JSON — T. Bray, Ed., 2017. The format all three build on.
Measured over 39,000 changes: Merge Patch is smaller 96% of the time and cannot express 10% of changes at all. When JSON Merge Patch cannot do the job →