Skip to content
FormatKit

Free online JSON patch generator

JSON diff you can apply, not just read

This JSON diff is free and needs no account: it lists every path that was added, removed or changed between two payloads, with the old and the new value beside each, and hands you the same change as an RFC 6902 JSON Patch or an RFC 7386 merge patch ready to send. Before the patch is shown it is applied to a copy of the source document and the result checked against the target, so a patch labelled verified is one that provably reproduces the file you asked for. Each side takes up to 5 MB, and long integer IDs survive the round trip with every digit.

  • 100% free
  • No signup
  • RFC 6902 and RFC 7386
  • Patch verified by replay
  • 5 MB payloads

Paste the document you have and the document you want. The patch that gets you from one to the other appears below.

How to generate a JSON patch

Source on the left, target on the right, patch underneath.

  1. Put the document you have on the left and the one you want on the right

    The left box holds the source the patch gets applied to; the right holds the target it has to produce. With the page focused, a plain Ctrl+V (⌘V on macOS) loads the clipboard into whichever box is still blank. Either box takes 5 MB, and anything that fails to parse has its line, column and cause printed directly underneath it.

  2. Read the operation list

    Every difference appears as one row: an op badge, the dot path it applies to — $.shipping.carrier, $.lines[2] — and the old value beside the new one. That is the human half of the answer, and it is generated from the same change list the patch is, so the two can never drift apart.

  3. Take the patch in whichever format your target speaks

    JSON Patch (RFC 6902) is the array of add, remove, replace and move operations you send with Content-Type: application/json-patch+json. Merge Patch (RFC 7386) is the smaller document-shaped form for application/merge-patch+json. Copy or download either; the JSON Patch is applied to a copy of the source and checked against the target first, and the badge says “replayed and verified” only when the result matched exactly.

Technical specifications

Output formatsRFC 6902 JSON Patch (add, remove, replace, move) and RFC 7386 JSON Merge Patch, downloaded as application/json-patch+json and application/merge-patch+json
VerificationEvery JSON Patch is applied to a copy of the source and compared with the target before it is shown; on a 5.33 MB pair that replay takes 234 ms and the badge only says verified when the result matched
Array-safe orderingRemovals emitted highest index first, additions lowest index first, and moves in between, so no operation shifts the index of one that follows it
Move operationsEmitted only when arrays are matched on an identity key; position matching uses add, remove and replace. Copy operations are never emitted
Number fidelityValues are printed from the source text, so a 19-digit ID reaches the patch unrounded; 1.0 and 1 are treated as one value and produce no operation
Merge-patch limits, flagged per pathA member set to null reads as a deletion when applied, and any change inside an array forces the whole array to be resent
Size and speed5 MB a side. Rendering the patch for a 5.33 MB pair of 24,000 records takes 130 ms; 300 operations are listed on screen and the patch preview stops at 3,000 lines, while copy and download are never truncated
Price and processingFree, account-free, and unmetered however many patches you generate; the two documents, the patch and the replay that checks it all live in this browser tab

Frequently asked questions

What is the difference between RFC 6902 and RFC 7386?

RFC 6902 JSON Patch is a list of instructions; RFC 7386 JSON Merge Patch is a sketch of the finished document. A JSON Patch is an array of objects — {"op":"replace","path":"/status","value":"shipped"} — that name a location with a JSON Pointer and say what to do there, so it can address a single element of an array, express a move, and be rejected cleanly if the source is not what the patch expected. A merge patch is an object shaped like the target: keys you include are set, keys you set to null are deleted, keys you leave out are untouched. Merge patch is far easier to read and to write by hand, and it pays for that by being unable to edit an array in place or to store a null.

How do I apply the patch this page generates?

Send it as the body of an HTTP PATCH request, or run it through a library in whatever language you use. HTTP PATCH is defined in RFC 5789 and the two formats have their own media types: application/json-patch+json and application/merge-patch+json — the download button already labels the file with the right one. Off the wire, python-jsonpatch gives you a jsonpatch command-line tool, fast-json-patch covers JavaScript, Newtonsoft.Json handles .NET and json-patch handles Go. Merge patches need no library at all in most languages, since the algorithm is a dozen lines of recursion.

Why are the remove operations listed from the end of the array backwards?

Because an RFC 6902 patch is applied one operation at a time, and removing an array element renumbers everything after it. Delete index 2 and the old index 5 becomes index 4, so a patch that lists removals in ascending order deletes the wrong things from its third operation onwards — a mistake that produces a patch which applies without error and leaves a wrong document behind. Emitting removals from the highest index down means no earlier operation can shift a later one. Additions run in the opposite direction for the same reason: ascending, so that every insertion point is already correct by the time it is used.

When does the patch use a move operation?

Only when arrays are matched by identity key, because that is the only mode in which an item can be recognised in its new position. Matching by position has no way to tell a moved item from a changed one — index 0 simply holds a different value than it did — so it emits replace, add and remove and nothing else. With an identity key, the survivors are lined up in their target order with move operations, which is both shorter and truer to what happened. Copy is never emitted: it saves nothing over add when the value is already in the patch, and it makes the patch harder to read.

Why can a merge patch not set a value to null?

Because null is the syntax merge patch uses for “delete this member”, so there is nothing left to say “set this member to null” with. RFC 7386 is explicit about the trade: it chose readability over completeness, and this is the price. The same limitation applies to arrays — a merge patch cannot change one element, so any array difference at all means the whole array is resent, however long it is. This page flags both cases as they arise, path by path, so you find out here rather than after the patch has silently dropped a field in production. When either one bites, switch to RFC 6902, which can express both.

Does the patch keep long integer IDs exactly?

Yes — values are copied out of the source text rather than round-tripped through JavaScript numbers, so a 19-digit snowflake ID or an order number above 9,007,199,254,740,991 reaches the patch with every digit intact. This is not a detail you can take for granted: a tool built on JSON.parse and JSON.stringify turns those values into 64-bit floats first, and the patch it emits then quietly targets or writes a number that differs from yours in its last few digits.

Is anything sent to a server?

No. Both documents are parsed, compared, patched and verified by JavaScript in this tab, so a payload full of real customer data can be turned into a patch without any of it crossing the network.

About JSON Patch and JSON Merge Patch

RFC 6902 came out of a practical problem with HTTP: PUT replaces a resource wholesale, which is wasteful when one field changed and unsafe when two clients are editing at once. The answer was a patch document — an array of operations, each naming a location with an RFC 6901 JSON Pointer and saying what to do there — sent with HTTP PATCH, itself defined a year earlier in RFC 5789. The format has six operations, and its most easily missed property is that they apply in sequence: each one sees the document as the previous one left it. That is what makes array indices treacherous. Two removals emitted in ascending order delete the wrong element the second time, and the patch does not fail — it succeeds and leaves you with a document nobody asked for. Emitting removals from the end backwards and additions from the front forwards is the whole trick, and it is why this page orders the operations the way it does rather than the way they read best.

The operation this page never emits is test, and it is worth knowing what you are missing. A test operation asserts that a location already holds a given value and aborts the entire patch if it does not, which turns a patch into an optimistic-concurrency primitive: assert the old value beside every replace and the patch becomes a compare-and- swap that cannot silently overwrite someone else’s edit. Whether you want that depends on how the patch is being used, and guessing wrong in either direction is worse than leaving it out — a patch full of unwanted assertions fails constantly against a live system. The old values are all listed here, so adding the tests you actually want is a mechanical edit.

RFC 7386 merge patch is the other half of the story and a much smaller specification: the patch looks like the document, present keys are set, null keys are deleted, absent keys are left alone, and anything that is not an object replaces its target outright. It is wonderfully readable and has two holes you will eventually fall into. Null is spent on deletion, so a merge patch cannot store one; and because an array is not an object, any change inside it means resending the array whole — change one element of a thousand-element list and the patch is a thousand elements long. Both are called out here per path as they occur. When you want to understand a difference rather than transmit it, the structural comparison page runs the same engine and reports what was ignored instead of what to change; the JSON viewer is where to go when a path in the operation list needs its surroundings explained, and the plain diff checker is the right tool when what you have is two files rather than two documents.

What happens to the two payloads

Both documents, the patch and the replay used to verify it all stay inside this browser tab. Nothing is uploaded and nothing is stored, so generating a patch from real production data does not put that data anywhere new.