Text Compare (Diff)
Compare two texts and see what changed, line by line and word by word, side by side or as a unified diff.
Text Compare - Find the Difference Between Two Texts
Paste an original text on the left and a changed version on the right, and every difference shows up at once: removed lines in red, added lines in green, and inside each changed line the exact words that were swapped. It works for contracts and articles as well as for source code, configuration files and log output, and both texts stay in your browser the whole time.
Spotting a changed number in a two-page document by eye is slow and unreliable. A diff checker does it in milliseconds and does not miss the comma that moved or the price that went from 40 to 45.
How to compare two texts
- Paste the original version into Original text and the new one into Changed text.
- The comparison appears below as you type, with a count of added and removed lines.
- Choose Side by side or Unified, and tick Ignore whitespace or Ignore case if those changes do not matter to you.
- Press Copy as unified diff to take the changes away as a patch.
Reading the result
| You see | It means |
|---|---|
| A red line on the left only | The line was removed |
| A green line on the right only | The line was added |
| A red and a green line side by side | The line was changed; the marked words are what changed |
| A grey bar with a count | Unchanged lines hidden to keep the changes in view |
Only changes and 3 lines around them is on by default, so a long file with two edits shows just those edits with a little context, the way a code review does. Untick it to see both texts in full.
Side by side or unified
Side by side puts the two versions in parallel columns with their own line numbers, which is the easiest way to read prose and to check a changed line against its original. Unified shows one column, with removed lines marked minus and added lines marked plus, which is how Git and most code review tools print a diff and uses less width on a small screen.
Word, character or line level
Lines are compared first. When a removed line and an added line are similar, they are placed next to each other and compared again, and Highlight inside lines decides how finely: Words suits prose and most code, Characters catches a single changed digit or letter in an ID or a hash, and Off shows whole lines only. Lines that have nothing in common are not forced into pairs, so an unrelated removal is not compared word by word with an unrelated addition.
Ignoring what does not matter
- Ignore whitespace treats lines that differ only in indentation, spaces or tabs as equal. Use it after reformatting code or when one editor converted tabs to spaces.
- Ignore case treats upper and lower case as the same, useful for SQL keywords or text retyped with different capitalisation.
- Line endings never count as a change: Windows and Unix line breaks are normalised before comparing.
How it works
The comparison uses the Myers algorithm, the same one Git uses by default. It finds the smallest set of added and removed lines that turns one text into the other, so the result shows what was really edited rather than a long list of moved lines. Lines the two texts share at the beginning and end are set aside first, which makes comparing two versions of a long file fast: a single change in a 20,000-line file is found in a fraction of a second.
Making a patch
Copy as unified diff produces a standard patch with --- and +++ headers and @@ hunks with three lines of context. Save it to a file and it applies with git apply changes.diff or patch -p0 < changes.diff, as long as the file names in the headers match yours.
Your texts stay private
Both texts are compared by JavaScript in the page. Nothing is uploaded or stored, which is what you want when comparing contract drafts, unreleased code or anything with personal data.
Related tools
To compare two JSON files, format both with the JSON formatter first so that key order and indentation match, then compare them here. To check whether two files are byte-for-byte identical without looking at the content, compare their checksums with the hash generator.