Text Diff

Text

Compare two text blocks line-by-line using the LCS algorithm with inline highlighting to review edits and merge conflicting changes side by side in one view.

4 → 5
AOriginal
apple
−banana
cherry
−date
BModified
apple
+blueberry
cherry
+elderberry
+date

About Text Diff

Plenty of situations need one answer: where exactly do these two texts differ. Comparing two configurations to see what changed, checking whether an API response survived a release unchanged, reviewing a paragraph a colleague rewrote, or tracing which lines disappeared from a piece of code between versions. Eyeballing long text reliably misses items, while a line-by-line comparison gives a definite answer. The algorithm, usually a variant of longest common subsequence, splits both texts into sequences of lines or characters, finds what they share, and marks the rest as additions and deletions. Line granularity suits code and configuration because one edit normally touches whole lines, while character granularity suits short text and sentences, resolving differences down to individual punctuation. That choice decides readability, and the wrong granularity yields a wall of red with no obvious point of interest. Practical notes: Normalize away the things that create phantom differences first, namely trailing whitespace, mixed tabs and spaces, and the final newline. Those three make two semantically identical files read as "almost every line changed", and the noise readily hides the real edit. Decide sensitivity explicitly too: ignoring whitespace is usually right when hunting configuration drift and wrong when verifying output content. Ordering matters for readability as well, with the old version on the left and the new one on the right, since review goes faster that way. Limits: The output reports textual differences rather than semantic ones, so reordering keys lights up the whole object even though the meaning is unchanged; sort keys before comparing to cut that noise dramatically. Reformatting, such as changing indentation from two spaces to four, produces a large diff, so format before comparing whenever you are verifying behaviour. Very large files consume significant memory in the browser, and beyond tens of megabytes a command-line tool is the better choice. And remember the tool cannot say which side is correct: it only presents differences, and judging them remains a human task. Data and privacy: what gets compared is usually configuration files, API responses and internal documents, which may contain secrets and customer information. This tool compares in the browser and never uploads the text, working fully offline, which makes it a better fit for internal material than most hosted diff services. The division of labour with version control matters here too: a VCS diff compares against a baseline and answers who changed what and when, whereas this tool compares two current states directly, which suits pre-review self-checks and ad hoc reconciliation. When several parties are involved, comparing each against the baseline and merging the results reads more clearly than diffing two versions against each other. For merge conflicts, exporting each side's changes and handling them section by section is safer than editing inside conflict markers, and afterwards run a full comparison again to confirm no leftover marker lines were committed. Making this tool a fixed pre-commit self-check catches a large share of the low-level but hard-to-trace mistakes such as accidentally editing an unrelated file along the way. Keeping the comparison alongside the commit message also lets you answer quickly, during a retrospective, exactly what that change touched.

How It Works Internally

Comparison uses a longest-common-subsequence approach to find what both sides share and marks the rest as additions and deletions. What it reports is textual, not semantic difference: reordered keys or indentation going from two spaces to four light up as large changes while the meaning is unchanged. Normalising line endings, whitespace and formatting first removes most of the noise.

Line-based output
InputA: a\nb\nc B: a\nB\nc
OutputCommon: a, c | Removed: b | Added: B (one replacement appears as one removal plus one addition)

Measured on This Page

Identical input0 added, 0 removed — no markers at all, rather than a fake all-green diff
One word changedhello world → hello brave world yields 1 added and 1 removed, pinpointing 'brave' at character level
Line insertedInserting a line yields 2 added and 1 removed: the line marker plus the intra-line character difference
Two-level granularityLines are aligned by LCS first, then paired lines get a character-level LCS — better than line-only at showing which words changed
HTML escapingDiff fragments pass through escapeHtml, so pasting text containing <script> cannot inject

A text diff is about locating change, not judging equality: line-level LCS says which lines moved and the character level says which words changed inside them (a one-word edit measured as exactly 1 added and 1 removed). Know the limit: LCS only finds the longest common subsequence, so moving a paragraph from top to bottom appears as a large deletion plus a large insertion rather than a move — a universal trait of LCS-based diffs, and move detection needs a different algorithm. Whitespace differences (trailing spaces, reindentation) count as real changes, so normalise indentation before diffing formatted code.

How this was measured: Three input pairs (identical / one word changed / one line inserted) checked for added-removed marker counts: identical must be 0, a one-word change 1 added and 1 removed, a line insertion 2 added and 1 removed (line level plus character level). · Measured 2026-10-31

How to Use

  1. Open "Text Diff"
  2. Paste the original version in pane A
  3. Paste the modified version in pane B
  4. Differences and line counts update live
  5. Use "Swap" to flip the two sides if needed

Use Cases

  • Config compare — Compare config files from two environments to find extra or missing fields fast.
  • Copy proofing — Match old and new copy to flag changed sentences and avoid missed edits.
  • Code review — Paste two function versions to see which lines changed as a lightweight diff.
  • Log comparison — Compare a normal vs. failing run log to isolate the differing lines for debugging.
  • Paste check — Confirm text copied from two places is identical, catching hidden character differences.
  • Translation proofing — Compare source and translated strings segment by segment to flag missing or mistranslated lines.

FAQ

Is the comparison line-based or character-based?

It highlights differences primarily by line; for changed lines you can clearly see which line moved, making the overall changes easy to scan.

Do spaces and line breaks count as differences?

Yes. Trailing spaces, indentation, and blank-line differences are all detected - exactly what you need to find invisible mismatches.

Do inconsistent line endings affect the result?

Yes. If one side uses CRLF and the other LF, nearly every line shows as changed; normalize line endings first so format noise does not mislead you.

Can it compare very large files?

Small to medium text is smooth; very long text (tens of thousands of lines) slows browser rendering, so compare in chunks or use a local diff tool.

Does it handle CJK text correctly?

Yes. It works at the Unicode level, detecting mixed-script and full-width/half-width differences.

Can I save the diff result?

You can copy the differences to save yourself; the tool keeps no text on any server and clears when you close the page.

Two clearly different texts show no differences — why?

Check invisible characters: full-width vs half-width, non-breaking spaces (U+00A0) and trailing from Windows line endings are invisible but participate in the comparison. Show whitespace or normalise first; character mode reveals them.

Comparing large texts is slow or freezes the tab?

Diff cost grows with the product of both lengths, so tens of thousands of characters slow down noticeably. Split by paragraph and compare only the differing fragments, or use line mode — an order of magnitude faster than character mode.