➖JSON Patch Remove Operation
Delete values from JSON objects and arrays
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
Examples
Remove from Object
Delete a property from an object
Patch:
Before:
After:
Remove from Array
Delete an item from an array by index
Patch:
Before:
After:
Remove Nested Value
Delete a deeply nested property
Patch:
Before:
After:
Real World: Deprecate an API Field
Drop a legacy field from a response payload
Patch:
Before:
After:
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
Working with arrays?
Index shifting, removing several elements in one patch, and the highest-index-first pattern - every array rule with runnable examples.
Read: JSON Patch and Arrays →
Remove Operation FAQ
What happens if the path does not exist?
remove fails and evaluation stops. RFC 6902 does not guarantee rollback of earlier operations. If you are unsure the value is there, guard the remove with a test operation first.
Does removing an array element shift the other indexes?
Yes. Every element after the removed one shifts one position left, so removing several elements in one patch needs care: remove from the highest index down.
How do I delete a value but keep the key?
That is not a remove - use replace with null: { "op": "replace", "path": "/field", "value": null }. The key stays, the value is cleared.
Try the Remove Operation Now
Use our free online JSON Patch generator to create remove patches instantly
🚀 Open JSON Patch Generator