๐Ÿ“

Text Diff API

Compare two texts and get structured diffs with statistics. Supports unified patch, JSON array, and inline word-level formats. Runs locally โ€” zero latency.

API Docs $0.001 / request

About this tool

Compare two text inputs and get a structured diff showing additions, deletions, and unchanged content. Choose between three output formats: unified (standard patch format), json (line-by-line structured array), or inline (word-level comparison). Includes stats on additions, deletions, and whether texts are identical. Runs entirely locally โ€” no external API calls.

Quick Start โ€” Unified Diff

curl -X POST https://api.iteratools.com/text/diff \ -H "Authorization: Bearer YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "text1": "Hello world\nThis is the original text\nLine three", "text2": "Hello world\nThis is the modified text\nLine three\nNew line four", "format": "unified" }'

Response (Unified)

{ "ok": true, "data": { "format": "unified", "identical": false, "diff": "Index: text\n===...\n-This is the original text\n+This is the modified text\n Line three\n+New line four", "stats": { "additions": 2, "deletions": 1, "unchanged": 2, "total_changes": 3 } } }

JSON Format Example

curl -X POST https://api.iteratools.com/text/diff \ -H "Authorization: Bearer YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"text1": "line one\nline two", "text2": "line one\nline three", "format": "json"}'
{ "ok": true, "data": { "format": "json", "identical": false, "diff": [ { "type": "unchanged", "value": "line one\n", "lines": 1 }, { "type": "removed", "value": "line two", "lines": 1 }, { "type": "added", "value": "line three", "lines": 1 } ], "stats": { "additions": 1, "deletions": 1, "unchanged": 1, "total_changes": 2 } } }

Parameters

  • text1 (required) โ€” Original text (max 100KB)
  • text2 (required) โ€” Modified text (max 100KB)
  • format (optional) โ€” Output format: unified (default), json, or inline

Output Formats

  • unified โ€” Standard patch format (like git diff). Returns a string.
  • json โ€” Line-by-line structured array. Each element has type (added/removed/unchanged), value, and lines count.
  • inline โ€” Word-level comparison. Each element has type and value. Great for highlighting changes within lines.

Response Fields

  • format โ€” The format used (unified/json/inline)
  • identical โ€” Boolean, true if texts are exactly the same
  • diff โ€” The diff output (string for unified, array for json/inline)
  • stats.additions โ€” Number of added lines/words
  • stats.deletions โ€” Number of removed lines/words
  • stats.unchanged โ€” Number of unchanged lines/words
  • stats.total_changes โ€” Total changes (additions + deletions)

Use Cases

  • Track changes between document versions in AI workflows
  • Compare LLM outputs across different prompts or models
  • Build version control features into content management systems
  • Detect plagiarism or content drift in web scraping pipelines
  • Validate code transformations and refactoring results
  • Generate change summaries for review workflows

Pricing & Limits

  • $0.001 per request via x402 micropayment on Base (USDC)
  • Max text size: 100KB per field
  • No external API calls โ€” instant response
Full Documentation Browse All Tools