API versioning guide
JSON Diff vs JSON Patch vs Merge Patch
A diff explains what changed. A patch is a document another system can apply. JSON Patch and JSON Merge Patch solve related problems, but their operation models and null behavior are different.
Open JSON Diff & CompareUse a diff for human review
JSON Diff & Compare reports added, removed, and changed paths without claiming that the report is an update instruction. It is the right first step for code review, configuration checks, and deciding whether a patch is appropriate.
Use JSON Patch for precise operations
RFC 6902 represents updates as an ordered array of operations such as add, remove, and replace. Paths use JSON Pointer, so array indexes and exact locations can be addressed.
Before
{ "name": "Ada", "active": false }After
[
{ "op": "replace", "path": "/active", "value": true }
]Use Merge Patch for object-shaped updates
RFC 7386 represents the desired changes as a partial JSON object. Object members merge recursively, while a null member removes the corresponding target member. Non-object patches replace the entire target.
Before
{ "name": "Ada", "active": false, "role": "viewer" }After
{ "active": true, "role": null }Choose by contract and ambiguity
Choose the format the receiving API specifies. If you control the contract, JSON Patch is more explicit and handles arrays precisely. Merge Patch is easier to read for object updates, but cannot use null as an ordinary replacement value because null means removal.
- Compare the source and target documents.
- Confirm whether the receiving endpoint accepts RFC 6902 or RFC 7386.
- Generate and review the patch.
- Apply it locally to a copy and compare the result with the intended target.
Common questions
FAQ
Is a JSON diff a standards-based patch?
Not necessarily. A diff describes changes; RFC 6902 and RFC 7386 define applicable patch documents.
What does null mean in Merge Patch?
A null member removes the corresponding member from the target object.
Which format is better for arrays?
JSON Patch addresses array indexes explicitly. Merge Patch generally replaces an array as a whole.