Skip to content
ZeroServer.tools

JSON Merge Patch Tool

Generate and apply JSON Merge Patch (RFC 7396) between two JSON objects.

Presets:
Original Size
105 B
Modified Size
108 B
Patch Size
79 B
Changes
4

About JSON Merge Patch

JSON Merge Patch (RFC 7396) is a simple format for describing changes to a JSON document. Unlike JSON Patch (RFC 6902), a merge patch mirrors the target document: a value in the patch replaces the one in the original, a null removes it, and anything the patch leaves out stays as it is. Use the Generate Patch tab to compute the smallest merge patch between two documents, or the Apply Patch tab to apply one. Numbers are compared by value and written exactly as typed, and any key works, __proto__ included. Notes under each result say what a merge patch cannot carry, such as a null in B. All processing happens entirely in your browser — no data is sent to any server.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Computing the merge patch between two documents.
  • Applying a patch to see the resulting document.
  • Producing a PATCH body for an API that accepts merge patch.
  • Understanding how a patch expresses a removal.
  • Checking a patch's effect before sending it to a live endpoint.

Frequently Asked Questions

What is JSON Merge Patch?
A patch document shaped like the target, defined by RFC 7396 (which replaced RFC 7386): present keys are set and null means delete. Applying {"a":1,"b":null} sets a and removes b. Its whole appeal is that the patch reads as a document rather than as instructions.
How is it different from JSON Patch?
JSON Patch (RFC 6902) is an array of explicit operations — add, remove, replace, move, test — addressed by JSON Pointer. It is more capable and much more verbose. Merge Patch is simpler and cannot express everything Patch can.
What is the null limitation?
You cannot set a value to null, because null already means delete. Where null is a meaningful value, use JSON Patch (RFC 6902) or send the whole document. When B holds a null, a note under the patch says so: applying the patch leaves that key out.
How are arrays handled?
Wholesale replacement. There is no way to modify one element or append — the entire array in the patch replaces the entire array in the target. For a long list with one changed item, that makes the patch as large as the document.
Which content type should the request use?
application/merge-patch+json for RFC 7396 and application/json-patch+json for RFC 6902, both on a PATCH request. Sending either as plain application/json leaves the server guessing, which is how a patch gets applied as a full replacement.
Can the patch or the document be an array or a plain value?
Yes, as RFC 7396 defines. A patch that is not an object, such as [1, 2], "text" or null, replaces the whole document, and an object patch applied to an array or a plain value starts from an empty object. A note under the result says when either happens.
Are numbers and key order kept?
Yes. Numbers are compared by value, so 1.0 and 1 are the same, and written as typed, so 59.90 stays 59.90 and a 20-digit ID is not rounded. The result keeps the original's key order and adds new keys at the end, in the patch's order. Any key works, __proto__ included.

Common errors and gotchas

  • Expecting a merge patch to modify one element of an array, which it cannot — arrays are replaced wholesale.
  • Confusing JSON Merge Patch with JSON Patch, which are different specifications with different media types.
  • Using null as a value rather than as a removal instruction, which merge patch cannot distinguish.
  • Assuming the API accepts merge patch, when many accept only JSON Patch or a full PUT.
  • Sending a patch with the wrong content type, which servers reject or misinterpret.
  • Misspelling the key that a null should remove, which then removes nothing; the tool names such a key in a note.

Related Developer Utilities tools

Private & free — this tool runs entirely in your browser.

IndieKit — Ship your Next.js startup in days.affiliate