JSON Patch vs JSON Merge Patch
JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7386) both update JSON, but they are not interchangeable. Patch is an ordered list of operations; Merge Patch is a partial document that overlays the original.
Open the tool, then paste the sample input below. Everything runs locally in your browser.
The problem
Developers often send one format to an endpoint that expects the other, or assume arrays behave the same way in both. JSON Patch describes precise add/remove/replace/move/copy/test operations. JSON Merge Patch is a simpler object where present keys overwrite, and null deletes a field.
The biggest gotcha is arrays: Merge Patch replaces an array wholesale, while JSON Patch can target an individual index.
Sample input
{
"name": "Asha",
"email": "asha@example.com",
"roles": ["user", "editor"]
}
[
{ "op": "replace", "path": "/email", "value": "new@example.com" },
{ "op": "remove", "path": "/roles/1" }
]
{
"email": "new@example.com",
"roles": ["user"]
}
Expected output
{
"name": "Asha",
"email": "new@example.com",
"roles": ["user"]
}
JSON Patch removes the single role at index 1. JSON Merge Patch replaces the entire roles array with ["user"]. They reach the same result here, but the array semantics differ.
How to do it
- Use JSON Patch when you need precise, ordered operations or array-element edits.
- Use JSON Merge Patch when a small partial object is enough and you replace whole arrays.
- Remember that in Merge Patch a
nullvalue deletes the key. - Match the
Content-Typeto the format your API expects. - Apply the change locally first to confirm the result before sending it.
Common mistakes
- Sending a JSON Patch array to an endpoint that expects Merge Patch.
- Expecting Merge Patch to remove a single array element — it replaces the whole array.
- Forgetting that
nullmeans “delete this field” in Merge Patch. - Using the wrong
Content-Typeheader for the body you send.
Related tools
Related guides
FAQ
Is JSON Patch the same as Merge Patch?
No. JSON Patch (RFC 6902) is an ordered array of operations. JSON Merge Patch (RFC 7386) is a partial document overlay where null deletes a field.
Which content type should I use for JSON Patch?
application/json-patch+json.
Which content type should I use for JSON Merge Patch?
application/merge-patch+json.
Which one is better for arrays?
JSON Patch, because it can add, remove, or replace a single element by index. Merge Patch can only replace the entire array.
Can I use JSON Patch for API partial updates?
Yes. JSON Patch is a common way to express partial PATCH updates when you need fine-grained or ordered changes.
Compare both formats side by side locally in your browser. Nothing is uploaded.
Schema validation, JSON Patch, JSON diff and JSONPath testing — grouped in one place.