Text Diff

Compare two blocks of text line by line, highlight added, removed and unchanged lines, with options to ignore case and surrounding whitespace, plus a change count. 100% client-side, nothing uploaded.

Original text
Changed text
Paste two texts, then click "Compare". Changed lines are highlighted.
Comparison result (left: original line number, right: changed line number)
The comparison result will appear here.

How a diff is computed

Comparing two texts means finding the smallest set of changes that turns one into the other. The classic approach is the longest common subsequence: keep everything the two versions share and flag the rest as added or removed. That is why a one-word edit shows as one small change rather than as two nearly identical lines.

Granularity changes everything

Compare byBest for
LineSource code, configuration files, logs, CSV exports
WordProse, legal text, documentation — shows exactly which words moved
CharacterShort strings, IDs, single-line fields

A line-level diff of two long prose paragraphs marks both as completely rewritten; a word-level diff of the same pair highlights only the dozen words that changed. Match the granularity to the material.

Unified diff notation

The format used by Git and the patch utility marks context lines with a space, removals with - and additions with +. A header like @@ -12,7 +12,8 @@ means the hunk starts at line 12 of the old file and line 12 of the new one, spanning seven and eight lines respectively. That is enough information to apply the change without the rest of the file.

Options worth turning on

Without these, a reformatted file produces a diff in which every line differs, which is technically true and practically useless.

Invisible differences that fake a whole-file change

When a diff reports that every line changed, the content was often identical and the file was simply stored differently. Three encoding-level differences produce exactly that symptom:

CauseWhat it looks likeFix at the source
CRLF versus LFEvery line differs; nothing visible on screenNormalise line endings in the editor, or pin them with .gitattributes
Byte-order markOnly the first line differsSave as UTF-8 without BOM
Different encodingsScattered garbage characters, or a binary comparisonDecode both sides as the same charset before comparing

These are worth fixing rather than filtering. An ignore-whitespace switch hides the symptom but leaves the repository with mixed line endings, which will resurface as a merge conflict later. The one exception is comparing a file you cannot control — a vendor export, a downloaded log — where ignoring whitespace is the only practical option.

Related tools

Line tools JSON formatter Markdown preview

FAQ

How does the text diff work?
The tool splits both texts into lines and compares them line by line with a longest-common-subsequence algorithm, marking lines that appear only on the left (removed), only on the right (added), and on both sides. Original line numbers are shown on the left and revised numbers on the right.
How large a text can it handle?
Normal config, code and document snippets are fine. To keep memory and speed reasonable, when the compared region is extremely large the tool degrades to a coarse “removed + added” comparison; for fine-grained results keep each comparison under a few thousand lines.
Can I ignore case or whitespace differences?
Yes. Checking “Ignore case” treats A and a as equal; checking “Ignore leading/trailing spaces” makes leading/trailing spaces and tabs not affect the comparison. The original content is still shown as-is; only normalization during comparison changes.
Is my text uploaded?
No. All comparison happens locally in your browser; your text is never sent to any server.