RFC 6902: Why the remove target location must exist
If applying a JSON Patch fails with a message like “remove operation target location must exist”, the path in your patch points at a field that is not in the document. RFC 6902 is strict: remove cannot silently skip a missing path.
Open the tool, then paste the sample input below. Everything runs locally in your browser.
The problem
In RFC 6902 JSON Patch, a remove operation fails when its path does not resolve to an existing member or array element in the target document. Unlike a merge-style update, it will not no-op on a missing field — the whole patch is rejected.
The fix is to point remove at a path that exists, correct the JSON Pointer, or guard the operation with a test first.
Sample input
{
"user": {
"id": 101,
"name": "Asha",
"email": "asha@example.com"
}
}
[
{ "op": "remove", "path": "/user/phone" }
]
Expected output
[
{ "op": "remove", "path": "/user/email" }
]
{
"user": {
"id": 101,
"name": "Asha"
}
}
The first patch is rejected because /user/phone is not present. The corrected patch removes /user/email, which exists, and succeeds.
How to do it
- Paste the original JSON document into JSON Patch & Pointer.
- Paste the patch array and apply it.
- If it fails, read which operation index and path were rejected.
- Confirm the path actually exists in the document (watch nested keys and array indexes).
- Either fix the path, or prepend a
testoperation so a missing target fails loudly and predictably.
Common mistakes
- Removing a field that is not present in the document.
- Mistyping a nested path, e.g.
/user/emaiinstead of/user/email. - Targeting an array index that is out of range.
- Writing JSONPath (
$.user.email) instead of a JSON Pointer (/user/email). - Expecting
removeto be ignored when the target is missing — it is not.
Related tools
Related guides
- JSON Pointer escaping: slash and tilde examples
- Apply JSON Patch online
- JSON Patch vs JSON Merge Patch
FAQ
Why does JSON Patch remove fail when the path is missing?
RFC 6902 requires the target location of a remove operation to exist. If it does not, the operation — and the whole patch — is rejected rather than skipped.
Can JSON Patch ignore missing paths?
No. Standard RFC 6902 has no “ignore if missing” flag. If you want optional removal, check the path first or guard it with a test operation and handle the failure yourself.
Should I use test before remove?
Often, yes. A test operation before remove asserts the current value and makes a stale or wrong patch fail clearly instead of corrupting the document.
Is /user.email a valid JSON Pointer path?
No. JSON Pointer uses slash-separated segments, so the correct path is /user/email. Dotted paths are JSONPath-style and will not resolve.
How do I remove an array item with JSON Patch?
Use the element index, e.g. { "op": "remove", "path": "/items/2" }. The index must point at an existing element; removing index 2 of a two-element array fails.
Test JSON Patch operations locally in your browser before sending a PATCH request. Nothing you paste is uploaded to a server.
Schema validation, JSON Patch, JSON diff and JSONPath testing — grouped in one place.