← Text

Text Diff

Paste an original and a changed version to see every added, removed, and unchanged line or word.

Texts to compare

Lines for code and lists; words for edited prose.
Options

Differences

Similarity
–
Added
0
Removed
0
Unchanged
0
Changed rows
0
removed in original only added in changed only

About this tool

This text diff tool compares an original and a changed version of any text and highlights exactly what was added, removed, and left alone. You can compare line by line, which suits code, lists, CSV rows, and configuration files, or word by word, which suits prose where a sentence was reworded. Options let you ignore letter case and whitespace differences. Results appear as a unified view with green additions and red deletions, and as a side-by-side table with line numbers, along with counts of added, removed, and unchanged items and an overall similarity percentage. It is useful for editors comparing drafts, developers checking a pasted snippet against a known version, and anyone who needs to confirm two documents really match.

How it works

The two texts are split into tokens, either lines or whitespace-separated words, and each token is optionally normalized by lowercasing it and collapsing runs of spaces before comparison. The tool then trims the common prefix and suffix and computes a longest common subsequence (LCS) of the remaining tokens with a dynamic-programming table. Tokens in the LCS are reported as unchanged; the rest are deletions from the original or additions in the changed text. Similarity is 2 × unchanged ÷ (tokens in A + tokens in B), the Sørensen–Dice coefficient over tokens, so identical texts score 100% and texts with nothing in common score 0%. To keep the browser responsive, word mode falls back to line mode above 4,000 tokens, and a block of more than 4,000 differing lines is reported as one replaced block rather than being aligned exactly.

Frequently asked questions

Should I compare by lines or by words?

Use lines for anything structured: source code, lists, spreadsheets exported as CSV, log files, or configuration. Use words for prose such as an edited paragraph, where a line-based diff would mark a whole sentence as changed because one word moved. Word mode keeps paragraph breaks as separate tokens so line breaks still line up.

What does the similarity percentage mean?

It is the Sørensen–Dice coefficient over tokens: twice the number of unchanged tokens divided by the total number of tokens in both texts. Identical texts score 100%. If half the lines in each version match, the score is 50%. Because it counts tokens rather than characters, a one-letter typo in a line counts the whole line as changed in line mode.

Does ignore whitespace also ignore blank lines?

No. Ignore whitespace collapses runs of spaces and tabs inside a line and trims the ends before comparing, so indentation changes and trailing spaces are not reported. Blank lines are still tokens, so an added or removed blank line shows up in the diff. Line endings (Windows CRLF versus Unix LF) are always normalized before comparison.

Why did the tool switch from word mode to line mode?

Aligning tokens with an exact longest-common-subsequence algorithm needs memory proportional to the product of the two token counts. Above 4,000 words per side after trimming the shared beginning and end, the tool falls back to line mode and shows a notice. Very long line diffs above the same cap report the differing region as a single removed block followed by a single added block.

Related tools

Word Counter · Case Converter · Lorem Ipsum Generator · Slug Generator · Line Tools · Find and Replace · Markdown Preview · Text Cleaner

Browse all Text Tools, or go back to every free tool on HeroYears.