Zero Signup ToolsFree browser tools

Developer Tools

JSON Merge Patch

Apply an RFC 7396 JSON merge patch to a document, or generate the minimal patch between two JSON documents. null deletes a member, arrays replace. No signup.

Apply an RFC 7396 merge patch to a target document. Members in the patch overwrite the target, a member set to null deletes it, and any array or scalar in the patch replaces the matching value wholesale.

177 chars

The JSON the patch is applied to

133 chars

application/merge-patch+json body

Patched document

5 changes

{
  "title": "Hello!",
  "author": {
    "givenName": "John"
  },
  "tags": [
    "example"
  ],
  "content": "This will be unchanged",
  "phoneNumber": "+01-123-456-7890"
}

What the patch changed

  • change$.title"Goodbye!" -> "Hello!"
  • remove$.author.familyNamemember removed (patch value was null)
  • change$.phoneNumber(absent) -> "+01-123-456-7890"
  • add$.phoneNumberadded "+01-123-456-7890"
  • array$.tagsreplaced with array(1)

How to use

  1. Choose a direction: Apply a patch to change a document, or Generate a patch by diffing two documents. Click Load sample for a worked example.
  2. In Apply mode, paste the target document on the left and the RFC 7396 merge patch on the right, then read the patched document and the change log.
  3. Remember the two rules the tool highlights: a member set to null is deleted, and an array or scalar in the patch replaces the matching value wholesale.
  4. In Generate mode, paste the original document on the left and the updated document on the right to get the minimal merge patch, with removed members emitted as null.
  5. Check the verification banner in Generate mode, which confirms the patch reproduces the updated document when applied to the original.
  6. Switch between Pretty and Minified output, copy the result, and in Apply mode use Use as new target to chain another patch on top.

About this tool

JSON Merge Patch implements the algorithm defined by RFC 7396, the standard that obsoletes the byte-identical RFC 7386, and exposes it both ways: applying a patch and generating one. A merge patch is itself a JSON document that describes how to change a target document, and its media type, application/merge-patch+json, is the body that a large number of REST APIs expect on an HTTP PATCH request. The rules are short but have sharp edges, so this tool follows the RFC pseudocode exactly. When the patch is an object, the algorithm walks each member: if the member also exists as an object on the target, it recurses and merges the two field by field, so members the patch never mentions are left untouched and you only transmit the fields that actually change. If a member in the patch holds a value, that value is written to the target. The one rule that surprises almost everyone is null: a member set to null in the patch deletes that member from the target, which means a merge patch can never set a member to the JSON value null, a documented limitation of the format rather than a quirk of this implementation. The other rule that bites is arrays. Merge patch treats arrays as atomic values, so an array in the patch replaces the entire target array even when only one element differs, and there is no positional, element-level array editing at all; when you need that, the right format is RFC 6902 JSON Patch with its add, remove, replace, move, and copy operations, which the companion JSON Patch Builder covers. Apply mode takes a target document and a patch and returns the patched result, with a change log that lists every member the patch added, overwrote, deleted, or replaced, and a heads-up when the patch tries to use null on a member that is not present, since that has no effect. Generate mode is the reverse: paste an original document and an updated one, and the tool produces the minimal merge patch that turns the first into the second, omitting unchanged members, emitting null for members that were removed, and carrying the new value for members that were added or changed. It then replays the generated patch against the original and confirms that the result reproduces the updated document exactly, so you can trust the patch before you send it; if either document contains a member explicitly set to null, which a merge patch cannot represent, the tool says so rather than emitting a patch that silently loses information. Output can be pretty printed with a two-space, four-space, or tab indent, or minified for a request body, and copied in one click, and in apply mode a Use as new target button lets you stack a second patch on the running result to mirror a sequence of PATCH requests. Everything runs locally: parsing, applying, and diffing all use the browser's native JSON parser, so the documents you paste are never uploaded, logged, or sent anywhere.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools