JSON Patch Documentation
Everything you need to know about RFC 6902 JSON Patch operations. A format for describing changes to a JSON document.
What is JSON Patch?
JSON Patch (RFC 6902) is a format for describing changes to a JSON document. It defines a JSON document structure for expressing a sequence of operations to apply to a target JSON document.
Instead of sending entire objects when making updates, JSON Patch lets you send only the specific changes needed. This makes it incredibly efficient for APIs, real-time applications, and data synchronization.
JSON Patch Operations
Adds a value to an object or inserts it into an array.
Replaces a value. Equivalent to a remove followed by an add.
Moves a value from one location to another.
Copies a value from one location to another.
Real-World Use Cases
REST API Updates
Send PATCH requests with only the changes instead of the entire resource. Reduces bandwidth and improves performance, especially for large objects.
Real-time Collaboration
Sync changes between multiple users editing the same document. Used by collaborative editors like Google Docs, Notion, and Figma.
Version Control
Track incremental changes to configuration files, database records, or any JSON data structure effectively.
Database Operations
Update only modified fields in NoSQL databases like MongoDB, CouchDB, or DynamoDB.
Best Practices
Always validate patches before applying them to prevent security issues
Use atomic operations when possible to ensure data consistency
Test operations to verify conditions before making changes
Order matters — operations are applied sequentially
Use meaningful paths that are easy to understand and maintain
Quick Links
Operation Deep Dives
Popular Libraries
JavaScript:
fast-json-patch
Python:
jsonpatch
Java:
jackson-json-patch
Go:
json-patch
PHP:
json-patch-php