{"uid":"cap_KWbkCD3atvJunq6MeJ7De","slug":"text-diff-unified-patch-counts-8e6a88e8","name":"Text Diff (Unified Patch + Counts)","description":"Compare two texts — unified diff patch plus added/removed/unchanged counts, by lines, words, or characters. Verify edits and detect changes deterministically.","url":"https://toolbelt402.tpoborne.workers.dev/text/diff","method":"POST","headers":{},"bodySchema":{"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)"}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.002","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_MjJ4nSeAZSnzO07GkZ0oi","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Compares two text strings and returns a unified diff patch plus added/removed/unchanged counts, with support for line, word, or character granularity.","exampleAgentPrompt":"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.'","exampleUseCases":[{"title":"Verify document edits before approval","prompt":"I need to verify what changed between the original draft and the revised version of this policy paragraph — can you do a line-by-line diff and tell me how many lines were added, removed, or stayed the same? Original: 'All employees must submit timesheets by Friday.' Revised: 'All employees must submit timesheets by Thursday at 5pm. Late submissions will not be accepted.'"},{"title":"Word-level change review for content editing","prompt":"Show me a word-level diff of these two sentences so I can see exactly which words my editor changed: original is 'The quick brown fox jumps over the lazy dog' and the new version is 'The swift brown fox leaps over the sleeping dog'."},{"title":"Character-level diff for code string comparison","prompt":"Can you do a character-by-character diff between these two short strings and tell me the exact characters added and removed? First string: 'config_timeout=30' and second string: 'config_timeout=300'."}],"resultDescription":"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).","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T18:49:51.431Z","isFirstParty":false}