JSON Merge Patch Tool
Generate an RFC 7386 JSON Merge Patch between two documents, or apply a patch to a document. Shows exactly which keys are set, replaced and deleted by the null convention.
Last reviewed by the Radiatus Cloud team
Need this built for your product?
We design, build & host secure software & APIs.
The patch format behind HTTP PATCH
When an API accepts PATCH with the content type application/merge-patch+json, it is implementing RFC 7386. The rules are deliberately small: a key present in the patch replaces the value at that key, a key whose value is null deletes it from the target, and objects merge recursively. Everything that is not an object, including arrays, is replaced wholesale rather than merged. That last rule surprises people constantly, because it means there is no way to append one element to an array with a merge patch.
Null means delete, which has consequences
Because null is the deletion signal, a merge patch cannot set a field to null. If your data model uses null as a meaningful value rather than as absence, merge patch cannot express it and you need JSON Patch, the more verbose RFC 6902 format with explicit operations. This is the single most important thing to establish before choosing between the two formats, and it is usually discovered after the API is built.
Generating and applying
Given an original and a target, the generator produces the minimal patch that transforms one into the other, emitting nulls for removed keys and recursing into nested objects rather than replacing them. Applying works in the other direction and shows the resulting document alongside a summary of which keys were added, changed and deleted, so a patch can be reviewed before it is sent to a live endpoint.
Related tools
- JSON Formatter — Format and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
- JSON Validator — Validate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
- Regex Tester — Test regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.
- HTML Minifier — Minify HTML by removing comments and redundant whitespace, without breaking inline elements or pre blocks. Runs entirely in your browser.
Frequently Asked Questions
Why can a merge patch not modify a single array element?
Because arrays are replaced, not merged. RFC 7386 treats any non object value as opaque, so changing one element means sending the whole array. If you need element level operations, use JSON Patch (RFC 6902) instead.
How do I set a field to null with a merge patch?
You cannot. Null is reserved for deletion. If null is a meaningful value in your model, either use a sentinel value or switch to JSON Patch, which has explicit add, remove and replace operations.
What content type should the request use?
application/merge-patch+json. Sending a merge patch as application/json is a common mistake, and a strict server will either reject it or apply the wrong semantics.
Is the generated patch minimal?
It contains only keys that differ, and recurses into nested objects rather than replacing them, so it is minimal in the sense the format allows. It cannot be smaller without changing the semantics.
What happens if the patch is not an object?
Then it replaces the entire document, which is what the specification says. The tool points this out, because a patch that is accidentally an array silently wipes the resource.
Privacy & Security
Everything runs in your browser; nothing is uploaded.
How to Use
Paste an original and a target document to generate a patch, or a document and a patch to apply it.
Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.
Related Tools
JSON Formatter
DeveloperFormat and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
JSON Validator
DeveloperValidate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
Regex Tester
DeveloperTest regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.