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.
Adds a value to an object or inserts it into an array.
Removes a value from an object or 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.
Tests that a value at the target location is equal to a specified value.
Send PATCH requests with only the changes instead of the entire resource. Reduces bandwidth and improves performance, especially for large objects.
Sync changes between multiple users editing the same document. Used by collaborative editors like Google Docs, Notion, and Figma.
Track incremental changes to configuration files, database records, or any JSON data structure.
Update only modified fields in NoSQL databases like MongoDB, CouchDB, or DynamoDB.
• 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
• JavaScript: fast-json-patch
• Python: jsonpatch
• Java: jackson-json-patch
• Go: json-patch
• PHP: json-patch-php