JSON Patch Generator
Derive RFC 6902 add, remove, and replace operations from two JSON documents.
Paste the current or before version of your JSON data.
Paste the new or after version to generate patch operations.
Patch choices
Object member order is ignored because it is not significant in JSON. Array changes are kept in generation order because RFC 6902 applies patch operations sequentially.
Generated output
Generated JSON Patch output will appear here.
A JSON Patch is an ordered program, not a sorted diff
RFC 6902 defines a patch as an array of operations that are applied one after another. The document produced by one operation becomes the input to the next, so reordering operations can change the result or make a previously valid array index fail.
Generation therefore keeps its original operation order. The emitted patch uses the standards-definedadd,remove, andreplaceoperations; it does not try to infermove,copy, ortest. RFC 6902
Every generated patch is applied once before it is shown
The comparison is not accepted merely because it produced plausible paths. After generation, the page applies the add/remove/replace sequence to a clone of the original JSON and checks that the result is exactly the modified JSON value. A verification failure is treated as an error rather than returning a patch that only looks right.
Object member order is ignored during equality checks because JSON objects are unordered collections of members. Array order is not ignored: changing an array's sequence is a real value change.
Array diffs are correct without pretending to be minimal
“Compare by index” replaces differing positions, removes surplus elements from the end toward the front, and then appends new positions. That sequence is verified, but an insertion near the beginning can still produce several replacements. Choose whole-array replacement when a compact, predictable patch is more important than field-level detail.
Paths follow JSON Pointer escaping exactly
JSON Patch paths are JSON Pointers. A member nameda/bis written as/a~1b, whilea~bbecomes/a~0b. The empty string is the pointer to the document root. RFC 6901
JavaScript parsing can otherwise hide changes
Duplicate object member names can collapse to one value during parsing, and very large or high-precision JSON numbers can be rounded by JavaScript number semantics. Both inputs are checked before parsing, so those cases stop with an error instead of producing a misleading patch.
If an identifier must preserve every digit, represent it as a JSON string. RFC 8259 explicitly notes interoperability concerns around duplicate names and numeric range or precision. RFC 8259
Old values belong in a report, not in the patch wire format
The optional old-value detail is retained for the report and full analysis output. JSON Patch output itself contains only members needed by the selected RFC 6902 operations, so a debugging annotation does not quietly become part of an API payload.
