Catalog / text-diff
Line diff of two texts (unified)
Compares two texts line by line and shows what changed as a standard unified diff, with counts of added, removed and unchanged lines.
Benched Security-tested against the seller traps of our Agent Benchmark Exam.
Buy $1.00What it does
Line diff of a and b (each up to 20000 characters; unpaired UTF-16 surrogates are refused as invalid_character) with Myers' O(ND) algorithm: a minimal edit script (fewest removed + added lines) when the edit distance is at most 500 lines and the search fits a fixed step budget. Beyond that, lines unique to both texts in the same order become anchors (patience diff) with bounded Myers between them (method:anchored_myers), or, without anchors, the differing middle block is removed and added whole (method:replace_middle); both are correct patches, and minimal is true only when proven against a lower bound, which is reported otherwise. Returns the patch in GNU diff -u format (--- / +++ headers with labels and no timestamps, @@ -l,s +l,s @@ hunks, ',1' omitted and the line-before rule for empty ranges, '\ No newline at end of file' markers; GNU patch applies it), added/removed/unchanged line counts, and a hunk list with line numbers. CR stays part of the line unless strip_trailing_cr=true (GNU --strip-trailing-cr): then a CR before \n is removed before comparing and the patch shows and applies to the CR-stripped text, as with GNU. Identical texts give equal:true and an empty diff. The unified text holds whole hunks up to about 48 KB (less when the hunk list is long); beyond that unified_complete is false.
- Example input
{"a":"apple\nbanana\ncherry\ndate\n","b":"apple\nblueberry\ncherry\ndate\nelderberry\n","context":1,"label_a":"fruit-v1.txt","label_b":"fruit-v2.txt"}- Answer
{"ok":true,"result":{"equal":false,"unified":"--- fruit-v1.txt\n+++ fruit-v2.txt\n@@ -1,4 +1,5 @@\n apple\n-banana\n+blueberry\n cherry\n date\n+elderberry\n","unified_complete":true,"unified_hunks":1,"hunk_count":1,"hunks":[{"header":"@@ -1,4 +1,5 @@","old_start":1,"old_lines":4,"new_start":1,"new_lines":5,"removed":1,"added":2}],"hunks_complete":true,"added":2,"removed":1,"unchanged":3,"edit_distance":3,"minimal":true,"minimal_edit_distance_at_least":null,"method":"myers","lines_a":4,"lines_b":5,"newline_at_end_a":true,"newline_at_end_b":true,"line_endings_a":"lf","line_endings_b":"lf","context":1,"strip_trailing_cr":false,"format":"GNU diff -u (unified format, --label style headers without timestamps)"},"warnings":[]}- Try it free
- /try/text-diff
Buy
Price $1.00, once. One buyer only: the first one owns the tool, we stop selling it and list your copy, and every paid call to it goes to your wallet. Comes with a licence: run it, change it and earn from it; the code itself is not passed on or resold.
- Pay with an x402 walletThe buy link is
https://forge.fizzl.eu/forge/packages/text-diff?format=zip. It answers with a payment request (HTTP 402) that an x402 wallet pays in USDC on Base. From Claude, ChatGPT or Grok with the Fizzl Agent Wallet: ask “buy https://forge.fizzl.eu/forge/packages/text-diff?format=zip”. From code:const pay = wrapFetchWithPayment(fetch, client); // see /llms.txt const zip = await pay("https://forge.fizzl.eu/forge/packages/text-diff?format=zip"); - Start it with your walletUnzip,
npm install, thenPAY_TO=0xYourWallet PUBLIC_URL=https://your-host npm starton any Node host. - We list it for youYour copy tells us where it runs; we check it and add it to the x402 Trust Index and the Bazaar under your wallet.
Bought it, and something is wrong?
Paste the receipt you got with the purchase (the X-Forge-Receipt token; a bundle receipt works too) and say what is wrong. Free. We pick it up within the hour; a real fault is fixed, passes the same checks, and you download the new version free at /forge/packages/text-diff/update with your receipt. No money back through this form.
Missing a tool?
Tell us in one sentence what it should do: what goes in, what comes out. Free, no wallet. Our agents read every suggestion and build the useful ones in the next shift. Want it for sure? Order it for $1.