Text Diff
Paste two versions of anything — a paragraph, a config file, a contract clause — and see exactly what changed, line by line and word by word, without uploading a thing.
⚙️ Comparison options
📊 Summary
🔀 Differences
added removed
How to use the text diff
- Paste the earlier version into Original text and the newer one into Changed text.
- Adjust the comparison options if you need to. Ignore case treats
Helloandhelloas the same line, Ignore all whitespace ignores every space and tab, and Trim leading and trailing spaces ignores only indentation and trailing blanks. - Read the summary: lines added, lines removed, lines unchanged and an overall similarity percentage.
- Switch between Side by side and Unified with the toggle. Side by side is easier for prose, unified is easier for code review and is what you export.
- Press Copy unified diff or Download .diff to take the result with you. Swap sides flips the two inputs if you pasted them the wrong way round.
How the comparison works
The diff runs in two passes.
The line pass treats each line as a single unit and finds the longest common subsequence — the longest list of lines that appear in the same order in both texts. Everything in that subsequence is unchanged; everything else is an insertion or a deletion. Before the expensive part runs, identical lines at the very start and very end are matched directly, which is what makes a small edit in a long document almost instant.
The word pass runs only on lines that were replaced. Each of those lines is broken into words, runs of whitespace and individual punctuation marks, and the same LCS algorithm runs again on those tokens. That is where the underlines come from: in side-by-side view a struck-through underline marks the words that went away and a plain underline marks the words that arrived, so you can see that one word changed rather than being told the whole line is different.
| Marker | Meaning |
|---|---|
| Red background | Line only in the original |
| Green background | Line only in the changed text |
| Struck-through underline | Word removed from this line |
| Plain underline | Word added to this line |
@@ -12,7 +12,8 @@ |
Unified hunk: 7 lines from line 12 on the left, 8 from line 12 on the right |
Colours come from the site’s theme variables, so the red and green stay legible in both light and dark mode, and every colour cue is paired with a shape cue — a prefix character in unified view, an underline in side-by-side — so the diff still reads without colour vision.
Worked examples
A single word changed. Compare “The quick brown fox jumps over the lazy dog.” with the same sentence using leaps. The summary reports 1 line added, 1 line removed and 0 unchanged, so similarity is 0 percent — the line-level view is brutal about a one-word edit. The word-level highlighting is what tells the real story: jumps struck through on the left, leaps underlined on the right.
A moved paragraph. Take a five-line text and move line 3 to the end. LCS reports it as one removal and one addition, giving 4 unchanged out of 6 total line slots and a similarity of about 80 percent. Diff algorithms in this family do not have a concept of “moved”; a move always shows up as a delete plus an insert.
Indentation-only changes. Re-indenting a 40-line config file from two spaces to four marks every line as changed and drops similarity to 0. Turn on Trim leading and trailing spaces and the same comparison reports zero differences, which is the fastest way to confirm that a reformatting commit changed nothing else.
Tips and common mistakes
- Start with trim, not with ignore-whitespace. Trimming ignores indentation while still catching a space added inside a sentence. Ignoring all whitespace also hides words that were merged or split apart.
- Ignore case is for content, not for code. In most languages
Valueandvalueare different identifiers, so leaving it off avoids a diff that quietly agrees with a real bug. - A low similarity score does not mean a big edit. Because it counts lines, a document written as one line per paragraph will always score low after small wording changes. Look at the word highlighting before drawing conclusions.
- Trailing newlines count. A file that ends with a newline has one more (empty) line than one that does not, which shows up as a single added line at the bottom. That is real, not a bug.
- Paste, do not retype. Retyping one side introduces differences that were never in the original, which is the most common reason a diff looks worse than expected.
- Windows line endings are handled. Carriage returns are normalised before comparison, so a file saved on Windows does not show up as entirely different from the same file saved on macOS.
Glossary
- LCS – longest common subsequence, the set of lines that appear in the same order in both texts.
- Hunk – a contiguous region of a unified diff, with a few lines of unchanged context around the changes.
- Context lines – unchanged lines kept around each change so you can see where it sits; this tool uses three.
- Unified diff – the single-column format with a leading space, minus or plus on every line.
Privacy
Your text never leaves your browser. Both inputs stay in the page, the comparison runs in JavaScript on your own device, and the exported .diff file is assembled locally and handed straight to your downloads folder. Nothing is uploaded, nothing is logged and closing the tab discards both versions — which makes this safe for contracts, credentials, patient notes, unreleased copy and anything else you would not paste into a hosted diff service.
Frequently asked questions
What algorithm does this use?
A longest common subsequence diff, the same family of algorithm behind the classic Unix diff. It is implemented with Hirschberg's divide-and-conquer variant, which keeps memory proportional to the shorter input instead of to the product of both, so a few thousand lines compare comfortably inside a browser tab.
Why does it sometimes align lines that look unrelated?
An LCS diff maximises the number of matched lines overall, not the number that a human would call related. If two distant lines happen to be identical, matching them can produce a shorter diff than keeping them apart. Turning on "Trim leading and trailing spaces" usually fixes the worst cases, because indentation changes stop hiding real matches.
What does the similarity percentage mean?
It is twice the number of unchanged lines divided by the total number of lines on both sides. Two identical texts score 100 percent, two texts with nothing in common score 0, and two empty inputs count as identical. It measures lines, not characters, so reformatting a paragraph can drop the score a lot even when the words barely moved.
Can I compare files rather than pasted text?
Open each file in a text editor and paste it in. There is no file picker because there is no upload step — everything happens in the page, and adding file reading would not change the privacy story but would add a lot of format guessing.
What is the line limit?
Each side is capped at 5,000 lines. Past that the tool shows a warning and compares only the first 5,000, because a worst-case comparison of two completely different 5,000-line files is already close to a second of work. For bigger files use a local diff tool or split the input.
Can I use the output as a patch?
The unified export follows the usual format with file headers and hunk headers, which is readable by humans and by most review tools. It is generated from pasted text rather than from files in a repository, so treat it as a readable record of changes rather than something to feed straight into a patch command.
Related tools
- Word CounterPaste or type your text and watch the counts update instantly — words, characters, reading time, keyword density and a readability score, all computed in your browser.
- JSON Formatter & ValidatorPaste JSON, get it beautified, minified or validated with the exact line and column of the problem. Everything runs in your browser.
- Case ConverterPaste text once and get every capitalisation style at the same time — sentence, title, camel, snake, kebab and a few playful ones — each with its own copy button.
- Lorem Ipsum GeneratorMake as much placeholder text as your mockup needs — in classic Latin or three alternative flavours — with optional HTML tags and a seed that reproduces the exact same text every time.
Last reviewed: