JSON Merge Patch Builder

Paste source and target JSON. The builder emits a minimal RFC 7396 JSON Merge Patch — a deep-merge document where null deletes keys and any non-object replaces the whole value. Simpler than RFC 6902 JSON Patch.

Merge Patch +4 ~1 −2
{
  "legacyField": null,
  "title": "RFC 7396 — JSON Merge Patch in 60 seconds",
  "author": {
    "email": null,
    "twitter": "@ada"
  },
  "tags": [
    "json",
    "patch",
    "merge-patch"
  ],
  "published": true
}

Send as PATCH with Content-Type: application/merge-patch+json

Apply-Patch Verification ✓ Matches target
{
  "title": "RFC 7396 — JSON Merge Patch in 60 seconds",
  "author": {
    "name": "Ada Lovelace",
    "twitter": "@ada"
  },
  "tags": [
    "json",
    "patch",
    "merge-patch"
  ],
  "published": true
}

Source merged with the patch — should equal your target.

About the JSON Merge Patch Builder

The JSON Merge Patch Builder diffs two JSON documents and produces a JSON Merge Patch — the deep-merge update format standardised by RFC 7396. Merge Patch is the simpler sibling of RFC 6902 JSON Patch: instead of an array of operations, the patch is itself a JSON document. Where a key is null it means "delete this key"; everything else is recursively merged into the target.

Paste a source document on the left, edit your target on the right, and the tool emits a minimal merge patch. Every patch is re-applied to the source so you can verify it produces the expected target — 100% client-side, no data leaves your browser.

RFC 7396 Rules at a Glance

Patch valueMeaning at that key
nullDelete the key from the source.
objectRecursively merge into the source. If the source had a non-object at that key, it is replaced with an empty object first.
arrayReplace the entire value. Arrays are never merged element-by-element under RFC 7396.
scalarReplace the value with the scalar (string, number, boolean).

Because null is reserved as the delete sentinel, JSON Merge Patch cannot set a key to literal JSON null. If you need that, use RFC 6902 JSON Patch instead.

How to Use the JSON Merge Patch Builder

  1. Paste your Source JSON on the left, or click Sample to load an example.
  2. Edit the Target JSON on the right — or click Copy source → target to start from an identical doc and edit only what changes.
  3. The generated merge patch appears below. The chip on top shows additions, modifications, and deletions at a glance.
  4. Use Apply-Patch Verification as a real-time sanity check: it applies the patch to the source and compares against your target.
  5. Click Copy to grab the patch JSON for your PATCH request body, test fixture, or migration script.
  6. Toggle Pretty output off to copy a minified patch suitable for embedding.

Common Use Cases

  • Build PATCH request bodies for REST APIs that accept application/merge-patch+json.
  • Generate Kubernetes strategic-style updates (kubectl patch --type=merge).
  • Express small config or feature-flag changes as a self-describing JSON document.
  • Snapshot the diff between two API responses to attach to a bug report or PR.
  • Convert "before/after" examples into a one-line migration payload.
  • Test client code that consumes RFC 7396 patches — both happy paths and key-deletion edge cases.

Frequently Asked Questions

What is JSON Merge Patch?

JSON Merge Patch is an IETF standard (RFC 7396) that describes partial modifications to a JSON document using a JSON document. It is widely supported in REST APIs, Kubernetes, and OpenAPI tooling.

How is this different from JSON Patch (RFC 6902)?

RFC 6902 JSON Patch is an array of explicit operations (add, remove, replace, move, copy, test) with JSON Pointer paths. RFC 7396 JSON Merge Patch is just a JSON document that mirrors your target shape — easier to read but less expressive. Use Merge Patch for everyday updates; switch to JSON Patch when you need atomic test ops, array element insertions, or to set a key explicitly to null. Need RFC 6902 instead? Try our JSON Patch Builder.

Why is my whole array showing up in the patch?

RFC 7396 does not diff arrays element-by-element. Any change inside an array (reorder, insert, remove) emits the entire new array. This is a spec limitation, not a tool limitation — if you need granular array operations, use JSON Patch (RFC 6902).

Can I set a key to JSON null with a merge patch?

No. null is the reserved "delete this key" sentinel in RFC 7396. There is no way to set a key to literal null through a merge patch. If your API needs that, switch to JSON Patch (RFC 6902).

Why does the patch sometimes equal the entire target?

When the source or target is not a JSON object (it's an array, string, number, boolean, or null), there is no sub-structure to merge — by RFC 7396 the patch is the new value itself. The "whole-document replacement" chip is shown in that case.

Which Content-Type should I send?

Content-Type: application/merge-patch+json for RFC 7396. RFC 6902 uses application/json-patch+json. Always check your API's documentation — some accept both, some only one.

Is my data sent to a server?

No. JSON parsing, diffing, and apply-patch verification all happen entirely in your browser. Your data never leaves your device — safe for confidential API payloads and internal documents.

Where can I use the generated patch?

Send it as the request body of a PATCH request, pass it to kubectl patch --type=merge, or feed it into any RFC 7396 library — for example json-merge-patch in Node.js, Python's jsonmergepatch, or your framework's built-in support.

Need granular operations or array element diffs?

Switch to the JSON Patch Builder for RFC 6902 patches with add, remove, replace, move, copy, and test operations — element-aware array diffs included.

JSON Patch Builder →