➖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" } } }

Real World: Deprecate an API Field

Drop a legacy field from a response payload

Patch:
{ "op": "remove", "path": "/user/legacy_id" }
Before:
{ "user": { "id": 7, "legacy_id": "x-99" } }
After:
{ "user": { "id": 7 } }

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

Other JSON Patch Operations