JSON Diff & Patch Generator
Generate and apply RFC 6902 JSON Patch operations locally.
How the JSON diff becomes a patch
Object keys are compared in sorted order so the same input produces the same operation sequence. Missing keys become remove operations, new keys become add operations, and changed primitive or array values become replace operations. Nested objects are traversed recursively, while every emitted path is escaped as an RFC 6901 JSON Pointer.
Patch application and failure behavior
- Array indexes are validated strictly, and the special - token appends only during add operations.
- Replace, remove, move, copy, and test require their source paths to exist; failures identify the operation number.
- Move rejects placing a value inside one of its own descendants and applies array index changes in operation order.
- Test uses structural JSON equality rather than object identity or serialized key order.
- Special object names such as __proto__ are created as own data properties without changing object prototypes.
Determinism, privacy, and review
Generation and application run entirely in this browser. The generated diff is intentionally predictable rather than guaranteed minimal, especially for arrays. Review operation order, array replacement cost, concurrent document versions, and application authorization before using a patch against persistent data or an API.
Related developer tools
Continue with JSON Pointer Evaluator, JSONPath Tester, JSON Validator.
How to Use JSON Diff & Patch Generator
- Paste valid source and target JSON values, or load the sample.
- Generate the deterministic patch and inspect each JSON Pointer path.
- Edit or paste any supported RFC 6902 operation sequence if needed.
- Apply the patch to the source and compare the separate result with the intended target.
Frequently Asked Questions
Which JSON Patch operations are supported?
- The applicator supports add, remove, replace, move, copy, and test. Generated patches use deterministic add, remove, and replace operations; changed arrays are replaced as one value instead of attempting an unstable element-by-element diff.
How are slash and tilde characters represented in paths?
- JSON Patch paths use RFC 6901 JSON Pointer. A slash inside an object key becomes ~1 and a tilde becomes ~0, so a key named a/b is addressed as /a~1b.
Does applying a patch change the source editor?
- No. The source JSON is cloned before operations run, and the result is shown separately. Removing the complete document root is rejected because the tool always returns a valid JSON value.
Sources & references
Primary references: RFC 6902: JavaScript Object Notation (JSON) Patch; RFC 6901: JavaScript Object Notation (JSON) Pointer; RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format.
Review policy: references and behavior notes are checked whenever the tool implementation changes.