JSON Patch Generator
Generate the minimal RFC 6902 JSON Patch operations that turn one JSON document into another — add, remove, replace and move, computed automatically by diffing the two documents — or paste an existing JSON Patch and apply it to see the result. Both directions run entirely in your browser.
Input
The document you want to end up with. The generated patch turns the original into this.
Options
Output
The generated patch in Generate mode, or the patched document in Apply mode.
| Op | Path | From | Value |
|---|---|---|---|
| No data yet | |||
Guides
JSON Patch Generator computes the exact RFC 6902 JSON Patch — the array of add/remove/replace/move operations — that turns one JSON document into another. Paste the original and the modified document and get back the patch you would send as an application/json-patch+json request body. It can also run the other direction: paste a patch and a document to apply it and see the result. Both directions run entirely in your browser.
How to use it
- Pick a Mode. Generate takes an original and a modified document and produces the patch that turns one into the other. Apply takes a document plus a patch and produces the patched result.
- Paste JSON into the two boxes. The result updates as you type.
- Copy or download the Result, and check the Operations table to see every
op/path/from/valueat a glance.
How the diff works
- Objects compare by key: a key only in the original becomes
remove, a key only in the modified becomesadd, and a key whose value changed on both sides recurses (orreplaces, for a primitive). - Arrays compare with a real sequence alignment (not just index-by-index), so inserting, deleting, or reordering elements produces a handful of
add/removeoperations instead of replacing every element from the change point onward. (For an extremely large array pair, the tool falls back to a faster positional diff and says so in the Operations table — the patch is still correct, just not guaranteed minimal for that array.) - Detect moved values (on by default) collapses a
removeimmediately followed by anaddof the exact same value into a singlemoveoperation — the common case of reordering an array element or renaming an object key without touching its value. copyandtestoperations are never generated (there's no reliable way to tell "this value was duplicated" from a value diff alone), but Apply understands both if you paste a patch that uses them.
What counts as "minimal"?
The generated patch is minimal by value: two array elements are only aligned as "the same element, unchanged" when they're exactly equal. If one field inside an array element changes, that element comes out as a remove of the old value plus an add of the new one, not a nested replace of just that field — matching "the same record with one field edited" needs identity information (an id field, position, similarity) a generic diff can't assume.
Is my data uploaded?
No. Both documents are parsed and diffed locally in your browser — nothing is sent to a server.
Related tools
For a simpler "sparse overlay" style of patch — set a key to null to delete it, no operation array — use the JSON Merge Patch Tool (RFC 7386). To see a read-only, side-by-side diff table without generating a patch, use JSON Compare. To test a single JSON Pointer path against a document, use the JSON Pointer Evaluator (RFC 6901).
Use it from code
From 3 credits per callREST API
curl -X POST https://api.iotools.cloud/v1/tool/json-patch-generator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"mode": "generate",
"baseJson": "{\n \"id\": 1,\n \"name\": \"Widget\",\n \"price\": 9.99…",
"modifiedJson": "{\n \"id\": 1,\n \"name\": \"Widget Pro\",\n \"price\": …",
"detectMoves": "true",
"indent": "2"
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `json-patch-generator` tool (JSON Patch Generator) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.