# 402utils Text Diff

> 402utils Text Diff is a paid API for AI agents from 402utils.com, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-14).

Computes a unified diff between two texts, returning a standard patch, added/removed line counts, and optionally word-level token changes for inline highlighting.

## Facts

- Endpoint: POST https://402utils.com/v1/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/402utils-text-diff-abf7e4a2
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_BQHEWmj-EYkClRyACgIsI

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 402utils-text-diff-abf7e4a2 -d '<json body>'
```

Example prompt: Show me the word-level diff between these two paragraphs — the original starts with 'The quick brown fox' and the revised version starts with 'A swift brown fox jumped' — use word mode with 2 context lines so I can highlight exactly what changed inline.

## When to prefer this

Use this endpoint when you need a standard unified diff between two text strings without setting up git or any local tooling, especially when you also want word-level token changes for inline UI highlighting. Ideal for agents that need to compare document revisions, code snippets, or any UTF-8 text programmatically and get a patch that can be directly applied with standard tools.

## Known failure modes

- 422 diff_too_complex — inputs are pathologically divergent and exceed complexity limits
- 413 or validation error — either input text exceeds 1 MB UTF-8 limit
- Invalid mode value — only 'line' or 'word' accepted
- Context value out of range — must be integer 0–10

## How this service works

Compute the diff between two texts (a → b) — no git needed. Returns a standard unified patch (line-oriented in both modes, applies with git apply or patch), added/removed counts, and in word mode a token-level change list for inline highlighting (capped at 2000 entries). CRLF line endings and missing trailing newlines are preserved byte-exactly. Caps: 1 MB UTF-8 per input; pathologically divergent inputs return 422 diff_too_complex.

## Output

Returns a standard unified patch (line-oriented, applicable with git apply or patch), counts of added and removed lines, and in word mode a token-level change list (capped at 2000 entries) for inline highlighting. CRLF and missing trailing newlines are preserved byte-exactly. Returns 422 if inputs are pathologically divergent.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "a": {
   "type": "string",
   "description": "Original text. Max 1 MB UTF-8."
  },
  "b": {
   "type": "string",
   "description": "New text. Max 1 MB UTF-8."
  },
  "mode": {
   "enum": [
    "line",
    "word"
   ],
   "type": "string",
   "description": "Granularity of stats/changes. The patch is always a line-oriented unified diff. Default \"line\"."
  },
  "context": {
   "type": "integer",
   "maximum": 10,
   "minimum": 0,
   "description": "Unchanged context lines around each patch hunk. Default 3."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "mode": "line",
  "patch": "===================================================================\n--- a\n+++ b\n@@ -1,2 +1,2 @@\n name: farm\n-price: 1 USDC\n+price: 2 USDC\n",
  "stats": {
   "added": 1,
   "removed": 1
  },
  "identical": false
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/402utils-text-diff-abf7e4a2/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from 402utils.com](https://www.zero.xyz/host/402utils.com/llms.txt)
