➖JSON Patch Remove Operation
Delete values from JSON objects and arrays
RFC 6902
remove operation
What is the Remove Operation?
The remove operation deletes the value at the specified path. When removing an array element, subsequent elements are shifted to fill the gap. The path must point to an existing value.
Syntax
{ "op": "remove", "path": "/path/to/target" }
Examples
Remove from Object
Delete a property from an object
Patch:
{ "op": "remove", "path": "/email" }
Before:
{ "name": "John", "email": "john@example.com" }
After:
{ "name": "John" }
Remove from Array
Delete an item from an array by index
Patch:
{ "op": "remove", "path": "/items/1" }
Before:
{ "items": ["a", "b", "c"] }
After:
{ "items": ["a", "c"] }
Remove Nested Value
Delete a deeply nested property
Patch:
{ "op": "remove", "path": "/user/address/zip" }
Before:
{ "user": { "address": { "city": "NYC", "zip": "10001" } } }
After:
{ "user": { "address": { "city": "NYC" } } }
Common Use Cases
- Removing items from shopping carts
- Deleting user preferences
- Cleaning up deprecated fields
- Removing array elements
Best Practices
- Always verify the path exists before removing
- Consider using test operation before remove for safety
- Removing non-existent paths will cause an error
Try the Remove Operation Now
Use our free online JSON Patch generator to create remove patches instantly
🚀 Open JSON Patch Generator