JSON patch apply
json-patch-apply · version 1.0.0 · JSON & JSONL · free, no key needed
Apply an RFC 6902 JSON Patch atomically; returns the document or the failing operation index and pointer.
Use when you need to: apply a JSON patch atomically · update a JSON document with patch operations · run RFC 6902 operations.
Decide before calling
Read the versioned contract and the supported scope below. Reuse json-patch-apply@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use json-patch-apply@1.0.0 for apply a JSON patch atomically. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- apply a JSON patch atomically
- update a JSON document with patch operations
- run RFC 6902 operations
- apply add remove replace move copy and test
- find which JSON patch operation failed
- patch JSON without partial changes
Not supported
- generate a patch between documents
- modify files on disk
Behavior
- Unrecognized operation members are ignored (RFC 6902 section 4); only the members defined for that op are interpreted. Removing the document root returns applied:false and reason root_removal_unsupported, preserving the original document: this JSON-result API cannot represent absence of a document.
- Implements RFC 6902 (April 2013), Sections 4 and 5, with JSON Pointer syntax from RFC 6901 (April 2013), Sections 3 and 4.
- Inputs are JSON values; object keys are compared exactly and arrays are ordered. Processing is synchronous and deterministic.
- Limits are checked before or during bounded traversal; no network, filesystem, clock, locale, or randomness is used.
Input
document(any JSON value, required)patch(array of object, required): max items 128
Output
standard_version(constant "RFC 6902 (April 2013); RFC 6901 (April 2013)", required)applied(boolean, required)document(any JSON value, required)failed_index(integer, optional): min 0; max 127failed_pointer(string, optional)reason(string, optional)
Limits
- max input bytes: 65536
- max operations: 128
- max depth: 32
- max output bytes: 131072
- max iterations: 4096
Example
Request input:
{
"document": {
"a": 1
},
"patch": [
{
"op": "replace",
"path": "/a",
"value": 2
}
]
}
Response:
{
"result": {
"standard_version": "RFC 6902 (April 2013); RFC 6901 (April 2013)",
"applied": true,
"document": {
"a": 2
}
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "json-patch-apply",
"version": "1.0.0",
"input": {
"document": {
"a": 1
},
"patch": [
{
"op": "replace",
"path": "/a",
"value": 2
}
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/json-patch-apply/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"document":{"a":1},"patch":[{"op":"replace","path":"/a","value":2}]}'
The machine-readable contract is at /v1/tools/json-patch-apply/versions/1.0.0.
CLI
node cli.mjs run json-patch-apply 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- JSON patch test only: Evaluate only RFC 6902 test operations without modifying JSON; returns each test result and whether all passed.
- JSON patch diff: Generate a deterministic RFC 6902 patch from two JSON documents; returns the ordered patch operations.
- JSON candidate list: Find and rank JSON object/array candidates in prose and Markdown fences (quotes and lists too) with exact raw spans.
- JSON schema instance locate: Resolve RFC 6901 instance locations (string or URI fragment) from schema errors to values, or say why they fail.
- JSON schema output validate: Validate JSON (e.g. LLM output) against a Draft 2020-12 schema subset; returns spec output units with JSON Pointers.
- JSON fence extract: List Markdown fenced code blocks (CommonMark 0.31.2) with exact spans, unwrapped content and an RFC 8259 JSON check.