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.

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.

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.

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.

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