FormatterHQ

JSON Patch Tester (RFC 6902)

Paste a JSON document and an array of RFC 6902 operations to see the patched result. If an operation fails, you get its number, type and the reason.

Loading tool…
Ready.

How to use the JSON Patch Tester (RFC 6902)

  1. Paste the target document into the JSON document editor.
  2. Paste your operations into JSON Patch operations as an array such as [{"op": "add", "path": "/a", "value": 1}].
  3. Click Apply patch. Operations run in order on a copy of your document.
  4. Check the Patched document, or read the error to see which operation failed.

Test JSON Patch operations online

JSON Patch (RFC 6902) describes changes to a JSON document as an ordered list of operations. Each operation names an op, a path written as a JSON Pointer, and a value or from where needed. It is sent with Content-Type: application/json-patch+json and is used by ASP.NET Core, Kubernetes --type json, Azure DevOps and many REST APIs.

This tester applies your operations one by one. If all succeed you see the final document; if one fails, processing stops and the message tells you which operation broke and why, the same all-or-nothing behavior a compliant server should have.

The six operations

opWhat it doesFails when
addAdds a key, or inserts into an array at an index (- means the end)The parent does not exist, or the index is beyond the array length
removeDeletes a key or array elementThe path does not exist
replaceReplaces an existing valueThe path does not exist
moveRemoves the value at from and adds it at pathfrom is missing, or you move a value into its own child
copyCopies the value at from to pathfrom is missing
testChecks that the value at path equals valueThe values differ

Example

Document:

{"name": "Widget", "price": 10, "tags": ["a", "b"]}

Patch:

[
  { "op": "test", "path": "/price", "value": 10 },
  { "op": "replace", "path": "/price", "value": 12 },
  { "op": "add", "path": "/tags/1", "value": "x" },
  { "op": "move", "from": "/name", "path": "/title" }
]

Result:

{
  "tags": ["a", "x", "b"],
  "price": 12,
  "title": "Widget"
}

Adding at /tags/1 inserts before the existing element rather than overwriting it. replace and move re-add their keys, so key order can change; JSON objects are unordered, so this does not affect meaning.

Reading error messages

  • Operation #2 (test): test failed: value at /price is 12 means an earlier operation already changed the value. Tests check the document as it is at that step, not the original.
  • Operation #1 (remove): Path /stock does not exist. Unlike merge patch, removing a missing key is an error.
  • array index "5" out of range appears when you add past the end of an array. Use /- to append.
  • Invalid JSON Pointer means a path does not start with /. The whole document is the empty path "", not "/".

JSON Pointer escaping

Paths use JSON Pointer (RFC 6901). A / inside a key is written ~1 and a ~ is written ~0, so the key "a/b" is addressed as /a~1b. If you are unsure of a path, click the value in the JSON path finder and copy its JSON Pointer.

JSON Patch vs. merge patch

JSON Patch can set explicit null values, edit single array items and guard changes with test. JSON Merge Patch is simpler to write but replaces arrays wholesale and uses null to delete. To produce a patch automatically from two versions of a document, use the JSON Patch generator.

Privacy

Patches are applied in your browser. Your document and operations are never uploaded.

Frequently asked questions

Are JSON Patch operations atomic?
RFC 6902 requires the whole patch to fail if any operation fails. This tester works on a copy and shows only an error when something fails, so you never see a half-applied result.
How do I append to an array with JSON Patch?
Use add with a path ending in /-, for example {"op": "add", "path": "/tags/-", "value": "c"}. A numeric index inserts at that position and shifts later items.
What is the difference between add and replace?
add creates the key if it is missing and overwrites it if it exists (for objects), while replace requires the key to exist already. On arrays, add inserts a new element and replace overwrites one.
Why does my test operation fail when the value looks the same?
test compares JSON values exactly, so 10 and "10" are different values, although key order inside objects is ignored. Also remember it sees the document after earlier operations in the same patch have run.
Can the patch be a single object instead of an array?
The standard requires an array. For convenience, this tester wraps a single operation object in an array, but a real server may reject it.

Last updated September 26, 2026

Guides

Related tools

JSON Merge Patch (RFC 7396) Apply an RFC 7396 JSON Merge Patch to a document, or create the merge patch that turns one JSON document into another. JSON Patch Generator (Diff to Patch) Compare two JSON documents and generate the RFC 6902 JSON Patch that transforms the first into the second, with optional test ops. JSON Path Finder Click any value in a JSON tree to get its path as JSONPath, JavaScript, Python, PHP, jq or JSON Pointer — or list every path. JSON Pretty Print Pretty print JSON online with a 4-space default, 2 or 3 spaces or tabs, and see the matching JavaScript, Python, PHP and jq commands. JSON Reader Open a .json file in your browser and read it as a collapsible tree, a sortable table or a graph, with a filter to find any value. JSON Schema to Sample JSON Generate realistic fake JSON that conforms to a JSON Schema — formats, enums, ranges and required fields respected. JSON Schema Validator Validate JSON against a JSON Schema (draft-07, 2019-09, 2020-12) with Ajv and get every error with its path and rule. JSON Serialize Online Serialize JSON into its most compact transport form, optionally wrapped as an escaped string literal for storage or messaging. JSON Sorter Sort JSON keys alphabetically at every level, ascending or descending. Optionally sort arrays of values for clean, comparable output. JSON Stringify Online Stringify JSON into an escaped string literal, exactly like JSON.stringify. Ready to embed JSON inside JSON, code or config values. JSON Syntax Highlighter Syntax highlight JSON with light, dark or Monokai themes and copy the colourised HTML for blogs, docs and slides. JSON to JSONL Converter Convert a JSON array to JSON Lines (JSONL / NDJSON), one record per line, for streaming, logging, BigQuery and ML datasets.