# Text Diff (Unified Patch + Counts)

> Text Diff (Unified Patch + Counts) is a paid API for AI agents from toolbelt402.tpoborne.workers.dev, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-14).

Compares two text strings and returns a unified diff patch plus added/removed/unchanged counts, with support for line, word, or character granularity.

## Facts

- Endpoint: POST https://toolbelt402.tpoborne.workers.dev/text/diff
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/text-diff-unified-patch-counts-8e6a88e8
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_KWbkCD3atvJunq6MeJ7De

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability text-diff-unified-patch-counts-8e6a88e8 -d '<json body>'
```

Example prompt: Compare these two versions of my contract clause word by word and give me a unified diff showing exactly what was added, removed, or unchanged — here's the original: 'The party shall deliver goods within 30 days.' and here's the revised version: 'The party shall deliver all goods within 14 business days.'

## When to prefer this

Choose this endpoint when you need a deterministic, human-readable diff between two text strings without setting up a local diff tool. It is ideal for document review, edit verification, and content auditing workflows where you want a unified patch plus quantitative change counts. Prefer it over the sibling JSON diff endpoint when comparing plain text rather than structured JSON documents. It supports three granularity modes (lines, words, characters), making it versatile for prose, code snippets, or any string comparison task.

## Known failure modes

- Missing one or both text inputs returns a 400 error
- Invalid diff mode value (not lines/words/characters) returns a validation error
- Extremely large text inputs may be rejected or time out
- Empty strings for both inputs return an empty patch with zero counts

## How this service works

Compare two texts — unified diff patch plus added/removed/unchanged counts, by lines, words, or characters. Verify edits and detect changes deterministically.

## Output

Returns a unified diff patch string showing added lines (prefixed with +), removed lines (prefixed with -), and context lines, along with integer counts of added, removed, and unchanged units (lines, words, or characters depending on the chosen mode).

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "a": {
   "type": "string",
   "description": "Original text (max 128 KB)"
  },
  "b": {
   "type": "string",
   "description": "Changed text (max 128 KB)"
  },
  "mode": {
   "enum": [
    "lines",
    "words",
    "chars"
   ],
   "type": "string",
   "description": "Diff granularity (default lines)"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/text-diff-unified-patch-counts-8e6a88e8/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from toolbelt402.tpoborne.workers.dev](https://www.zero.xyz/host/toolbelt402.tpoborne.workers.dev/llms.txt)
