JSON Merge Patch (RFC 7396)

Apply a JSON Merge Patch (RFC 7396) — the dead-simple alternative to RFC 6902 JSON Patch. A merge patch is just a JSON object: each property in the patch replaces (or recursively merges into) the corresponding property in the target. Set a property to null to delete it. Used by GitHub's API, Kubernetes's strategic merge patch, and many REST APIs.

How to use the JSON Merge Patch (RFC 7396)

Paste the original document on the left and the patch on the right. The applier walks both: scalar values in the patch overwrite; objects merge recursively; null values in the patch delete the corresponding property from the target. Arrays in the patch replace arrays in the target (no element-level merging).

What is the JSON Merge Patch (RFC 7396)?

RFC 7396 JSON Merge Patch was designed to be the simplest possible patch format: a patch is itself a JSON document, and applying it follows three rules. (1) Object properties in the patch replace properties in the target (or merge if both are objects). (2) Properties with value null in the patch are removed from the target. (3) Anything else is a value replacement.

The trade-off vs RFC 6902 JSON Patch: merge patch can't describe array element changes (you always replace the whole array), can't move/copy values, and can't distinguish "set to null" from "delete". For most CRUD APIs, that's fine; for diff-style patches, use RFC 6902 (our JSON Patch builder).

Frequently asked questions

How does JSON Merge Patch differ from JSON Patch (RFC 6902)?

A merge patch is just a partial JSON object merged into the target, which is simpler to write. JSON Patch is an explicit list of add, remove and replace operations and can express things merge patch cannot, like editing a single array element.

How do I delete a field with a merge patch?

Set that field to null in the patch. The applier removes the key from the target rather than setting it to null.

Why can a merge patch not set a value to null?

Because null is reserved to mean deletion in RFC 7396. If you need to store a literal null, use JSON Patch instead.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: