How Text Diff Works
The tool splits each input into lines and runs an LCS (longest-common-subsequence) algorithm — the same algorithm used by git diff — to find the minimum set of edits that transforms Text A into Text B.
- + Green lines — lines present in Text B but not in A (added)
- – Red lines — lines present in Text A but not in B (removed)
- White lines — identical in both (unchanged)
Line numbers are shown for both sides so you can navigate directly to the change in your editor. The Ignore case toggle normalises both sides to lowercase before comparison, so Hello and hello count as equal. The Ignore whitespace toggle trims leading and trailing spaces from each line before comparing — useful for config files where indentation varies between environments.
Works on any plain text: source code, JSON, YAML, SQL queries, log files, config files, Markdown, CSV, or plain prose. For structured JSON comparison with key-by-key analysis that ignores key ordering, use the JSON Diff tool instead.
When to Use Text Diff
Any time you have two versions of the same file and need to know exactly what changed:
- Config file review — compare
nginx.conf,docker-compose.yml, or.envbefore and after a change before pushing to production. - Log analysis — paste two log snapshots and instantly spot lines that appeared or disappeared between them.
- AI-generated code review — compare an AI-suggested snippet against your existing code to see what was added or removed.
- Search-and-replace audit — verify a bulk find-and-replace only touched what you intended and didn't silently alter other lines.
- SQL query comparison — diff two versions of a long query to catch a missing
WHEREclause or an accidental column rename. - Documentation comparison — compare two Markdown drafts to see what copy was added, reworded, or cut.
- Contract or spec review — compare two versions of an OpenAPI or JSON Schema spec to see which endpoints or fields changed.
Text Diff vs JSON Diff — Which Should You Use?
| Feature | Text Diff | JSON Diff |
|---|---|---|
| Input type | Any plain text | Valid JSON only |
| Comparison method | Line-by-line LCS | Recursive key-by-key |
| Handles key reordering | No — shows as change | Yes — order-independent |
| Nested path display | No | Yes (e.g. user.address.city) |
| Ignore whitespace option | Yes | N/A (parsed before compare) |
| Best for | Code, configs, logs, Markdown | API responses, JSON data |
Frequently Asked Questions
How does the text diff tool work?
It splits both texts into lines and runs an LCS diff — the same algorithm behind git diff. Lines only in B are green (added); lines only in A are red (removed); shared lines are white (unchanged).
Is my text sent to a server?
No. Everything runs in your browser with JavaScript. Your text never leaves your device.
What kinds of text can I compare?
Any plain text: source code, JSON, YAML, Markdown, config files, SQL queries, log output, CSV, or prose. The tool is completely language-agnostic.
Does it ignore whitespace or case?
By default, comparison is exact. Use the Ignore case and Ignore leading/trailing whitespace checkboxes to relax those constraints.
What is the difference between Text Diff and JSON Diff?
JSON Diff is structure-aware: it parses both inputs as JSON and compares objects key-by-key, so reordered keys don't produce false positives. Text Diff is line-based and works on any text, but treats input as plain characters — not structured data.
Is there a character or line limit?
There is no hard limit. Very large files (tens of thousands of lines) may take a moment to compare, since LCS runs in the browser.
Can I diff JSON files with Text Diff?
Yes — JSON is plain text, so Text Diff works on it. However if the same data is formatted differently (different indentation, reordered keys) Text Diff will show many false-positive changes. For JSON-specific comparison, use JSON Diff which parses the structure before comparing.
Why does swapping A and B show the same number of changes?
By design — a diff is symmetric. Lines added going from A→B become lines removed going from B→A, and vice versa. The totals stay the same; only the green/red colouring is mirrored.