JSON Merge Patch (RFC 7396)

Client

Combine a base JSON value with a merge-patch object: nested objects merge recursively, nullremoves keys, and non-object patches replace the document—different from the operation-array JSON Patch (RFC 6902) on the Pointer & Patch page.

Learn more: Merge patch vs JSON Patch

Apply an RFC 7396 merge patch object to a base JSON value: objects merge recursively, `null` removes a key, and non-object patches replace the whole document.

Compared to RFC 6902

JSON Patch (RFC 6902) is an array of operations (`add`, `remove`, `replace`, …). Merge patch is a single JSON object that looks like a partial document—often smaller for config overlays.

Arrays

Merge patch does not merge array elements by position; a patch replaces an entire array value when you set that key. Use JSON Patch or a custom merge if you need fine-grained list edits.

Apply merge patch

?

A merge patch is a JSON object describing edits: nested objects merge recursively; null removes a key from the base; arrays and scalars replace wholesale. This differs from JSON Patch (RFC 6902), which uses an array of operations.

If the patch is not an object (for example an array), the result is the patch alone—replacing the base document.

Nearby workflows on Toolcore

Common use cases

  • Apply small PATCH bodies that only list changed keys instead of posting the full JSON document.
  • Remove keys explicitly by setting them to null in the merge patch, per RFC 7396.
  • Compare behavior with JSON Patch (RFC 6902) on the Pointer & Patch page when you need operation lists versus merge objects.
  • Preview what an HTTP PATCH handler would produce from a merge-patch body before wiring the same logic on the server.

Common mistakes to avoid

  • Treating null as “leave unchanged”

    In merge patch, null means delete the key at that path. Omit the key instead if you want to preserve the base value.

  • Using merge patch for non-object roots

    If the patch is not an object, it replaces the entire document. Double-check primitive and array roots.

  • Expecting arrays to merge element-by-element

    Like deep merge, a merge patch replaces whole arrays when the patch contains an array at that path. Use JSON Patch or app-specific logic if you need splice or merge-by-id behavior.

FAQ

Does merge patch run on your servers?

No. Base and patch JSON are combined locally in your browser.

When should I use JSON Patch instead?

Choose JSON Patch when you need ordered operations, array moves, or precise test/remove semantics. Merge patch is smaller for simple key/value updates.

How is this different from the JSON deep merge page?

Deep merge overlays two full documents without RFC 7396 null-to-remove semantics. Merge patch follows the standard: nested objects merge, null deletes keys, and non-object patches replace the entire value.

Related utilities you can open in another tab—mostly client-side.