{"uid":"cap_BQHEWmj-EYkClRyACgIsI","slug":"402utils-text-diff-abf7e4a2","name":"402utils Text Diff","description":"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.","url":"https://402utils.com/v1/diff","method":"POST","headers":{},"bodySchema":{"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."}}},"responseSchema":{"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}},"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_oPktRq6Xez-MXHkcYgaGp","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":"Computes a unified diff between two texts, returning a standard patch, added/removed line counts, and optionally word-level token changes for inline highlighting.","exampleAgentPrompt":"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.","exampleUseCases":null,"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T13:07:06.574Z","isFirstParty":false}