Text Diff

Compare two text blocks and highlight added, removed, and unchanged lines side by side.

How the Diff Works

The tool computes a Longest Common Subsequence (LCS) between the two texts — the maximum set of lines that appear in both, in the same order — then marks everything else as an addition or a deletion. This is the same underlying problem git diff solves, though git specifically uses Myers' algorithm, a more efficient way of finding that same shortest edit script (see below for the difference).

Lines are compared exactly — whitespace matters. A line with a leading space is different from one without.

This Tool's LCS vs. Git's Myers Diff

Both approaches solve the same underlying problem — find the smallest set of line changes that turns text A into text B — but differ in how efficiently they get there:

This tool (classic LCS)Git diff (Myers)
PublishedFoundational CS algorithmEugene Myers, 1986 — "An O(ND) Difference Algorithm"
Time complexityO(m×n) — grows with both texts' full lengthO(ND) — grows with the number of differences, not total size
Best forTypical text blocks, config files, short documentsVery large files where most lines are unchanged
ResultSame correct minimal diffSame correct minimal diff, computed faster at scale

For the sizes most people paste here — a few hundred to a few thousand lines — the difference is imperceptible. Myers' advantage shows up on huge files with small diffs, which is exactly git's use case (comparing full source files where only a handful of lines actually changed).

Use Cases

  • Comparing config file versionsSee exactly which lines changed between two versions of a YAML, .env or INI file before deploying.
  • Reviewing documentation changesDiff two drafts of a README or markdown doc without needing a git repository set up locally.
  • Checking log output before/after a fixPaste log output from before and after a code change to confirm the fix altered exactly the lines you expected.
  • Comparing API responses across environmentsSpot drift between a staging and production response body that should otherwise be identical.
  • Spotting differences in query outputCompare two SQL result dumps or CLI outputs line by line without opening a full diff tool or IDE.

Frequently Asked Questions

Use the JSON Diff tool — it understands JSON structure and ignores key ordering differences, which this text-level diff cannot do.

Yes — lines are compared as exact strings including leading/trailing whitespace. Normalize indentation before diffing if you only care about content.

The LCS algorithm runs in O(m×n) time and memory. For very large files (10,000+ lines each), performance may degrade. Use git diff for large codebases.

No — binary files contain non-text bytes. This tool is designed for plain text content only.

They solve the same problem (finding the minimal set of line changes) but git specifically uses Myers' algorithm, which is more efficient — O(ND) based on the number of differences rather than O(m×n) based on total text size. For typical text and config file sizes, both produce the same correct result at effectively the same speed.

Paste the previous and revised versions here to see every changed line highlighted, which catches subtle wording changes a side-by-side read can miss — a common use case for tracking amendments, redlines, and revision history outside of a version-control system.

Related Tools