Free, browser-based utilities for everyday developer workflows

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 this example in JSON Patch & Pointer

Open the tool, then paste the sample input below. Everything runs locally in your browser.

Open this example in JSON Patch & Pointer →

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

Original document
{
  "name": "Asha",
  "email": "asha@example.com",
  "roles": ["user", "editor"]
}
JSON Patch (RFC 6902)
[
  { "op": "replace", "path": "/email", "value": "new@example.com" },
  { "op": "remove", "path": "/roles/1" }
]
JSON Merge Patch (RFC 7386)
{
  "email": "new@example.com",
  "roles": ["user"]
}

Expected output

Both produce
{
  "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

  1. Use JSON Patch when you need precise, ordered operations or array-element edits.
  2. Use JSON Merge Patch when a small partial object is enough and you replace whole arrays.
  3. Remember that in Merge Patch a null value deletes the key.
  4. Match the Content-Type to the format your API expects.
  5. 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 null means “delete this field” in Merge Patch.
  • Using the wrong Content-Type header 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.

Explore more JSON and API contract tools

Schema validation, JSON Patch, JSON diff and JSONPath testing — grouped in one place.

View the JSON & API contract toolkit →