Skip to content

JSON Merge Patch

Create or apply a JSON Merge Patch as defined in RFC 7396. In create mode, compare an original and a target document to get the smallest merge patch between them. In apply mode, merge a patch into a document, where null removes a key and objects are merged recursively.

Reset

Frequently asked questions

What is a JSON Merge Patch?

A merge patch, defined in RFC 7396, is a JSON document that looks like the changes it describes. Keys with values set or replace, keys set to null are removed and nested objects are merged. APIs accept it with the media type application/merge-patch+json.

How is it different from JSON Patch?

JSON Patch (RFC 6902) is a list of operations with paths. A merge patch is simpler to read and write, but it cannot set a value to null, and it always replaces whole arrays rather than changing single items.

Why does create mode reject my target?

In a merge patch, null means remove the key, so a target that sets a key inside an object to null cannot be expressed. The message names the path. Use JSON Patch for such changes.

How are arrays handled?

Arrays are never merged item by item. If an array differs, the patch contains the whole new array, and applying it replaces the old array completely.

What if the patch is not an object?

Following RFC 7396, a patch that is not an object, such as an array or a string, replaces the whole document.

What does an empty patch mean?

In create mode, {} means the two documents are equal. Applying {} to a JSON object leaves it unchanged.

About OneClick Pro

OneClick Pro is a free collection of more than 150 web tools for everyday work: converting images and units, formatting and validating code, checking domains and SEO, and working with text, dates and numbers. Every tool runs without registration or subscription, and what you enter is only used to calculate your result and is never stored. Use it as a quick toolbox for one-off tasks, or bookmark the tools you rely on every day.