Text

Text Diff

Compare two texts line by line — what was added, removed, or changed, with word-level highlighting inside changed lines.


                        
                    

Text Diff compares two texts line by line and shows what was added, removed, or changed, with word-level highlighting inside changed lines — much like git diff, but without a command line.

How to use it

Common uses

Things to keep in mind

By default a whitespace-only change (like indentation) still counts as a difference, since it technically changes the line's content.

The diff compares lines by position, so adding or removing a single line near the top can shift how the rest of the text lines up.

Article about this tool: Text Diff: how algorithms find the difference between two texts

Frequently asked questions

How is the comparison calculated?

The comparison happens line by line: each line is identified as added, removed, or changed, and within changed lines, the exact words that differ are highlighted.

How are additions, deletions, and changes displayed?

Added and removed lines are flagged as such in the result, and changed lines show word-level highlighting to immediately spot what changed without rereading the whole line.

Are my two texts sent to a server?

No, the comparison runs entirely in the browser in JavaScript — no content is sent anywhere.

Why does inserting a single line show every following line as changed?

The algorithm doesn't always correctly recognize that it's an insertion rather than a bulk replacement — especially when the surrounding lines are similar to each other. Good diff algorithms try to minimize these false positives by searching for the longest common subsequence, but it's not always perfect.

Does the comparison account for whitespace?

Yes, by default a change in whitespace alone (like indentation) is also flagged as a difference, since technically it's still a change to the line's content.

Articles: Text

Case Converter: why different naming styles exist

Why one project writes variables in camelCase but files in kebab-case, and where these rules came from.

Regular expressions: basic syntax and common patterns

How to read a regular expression, and how greedy matching differs from lazy matching.

Sorting and deduplicating lines: why it matters

Why numeric sorting putting "10" before "9" is a mistake, and how to avoid it.

String Escape: why the same text needs escaping differently

Why the same quote character gets escaped differently in a JS string, JSON, and a shell command.

CRLF vs LF: why line ending characters still matter

Why a file written on Windows can show as "entirely changed" in git on Linux.

Counting characters and words: why it's not always trivial

Why an emoji or an accented character can count as several characters at once.

Lorem Ipsum: where the placeholder text came from and why it exists

Why designers deliberately use "nonsense" text instead of real content in mockups.

Slugify: turning arbitrary text into a URL

How a title like "Hello, World!" turns into a URL-safe string like hello-world.

Markdown: why plain-text syntax beat rich text editors

Why developers choose to write documentation in Markdown instead of a rich text editor.

Whitespace and invisible characters: the hidden cause of weird bugs

Why two strings that look identical can fail to match because of an invisible character.

Text Reverse: why "reversing text" is harder than it sounds

Why a naive string reversal can turn an emoji into unusable bytes.

Text frequency analysis: why count how often words repeat

How letter frequency in ciphertext helps crack the simplest substitution ciphers.