Text Compare: Find Differences Between Two Texts or Files

November 11, 2026 · 11 min read

Text Compare: How to Compare Two Texts and Files for Differences

A text compare tool lines up two versions of the same text and marks every line, word or character that was added, removed or changed. Paste both versions into our free diff checker for a quick answer. For files, Word documents and code, the built-in commands and editor features below do the same job.

What a Text Compare Tool Does With Your Two Versions

Every diff checker starts with two inputs: the original and the changed version. It finds the longest sequence of lines, words or characters the two share in the same order, then reports everything outside that sequence as added or removed. Unchanged parts stay plain, so your eye goes straight to the edits.

Many diff tools build on an algorithm Eugene Myers published in 1986, which finds the shortest list of edits that turns one text into the other. Our tool uses jsdiff, an open-source JavaScript library that implements it. When you run a text compare online with it, the work happens in your browser, and browser-based tools on this site have no daily limit.

You get two views of the result. The side-by-side view puts the original on the left and the changed text on the right. The unified patch is a single block of + and - lines that you can copy into a ticket, an email or a code review.

Line, Word or Character: Picking the Comparison Level

The same edit looks very different depending on what the tool treats as one unit. Take this one-line change in a set of release notes:

Before: Improved export speed by 20%.
After:  Improved export speed by 35% on mobile.

Here's what each level reports for it:

LevelWhat it flagsBest for
LineThe whole line removed and a new line addedCode, config files, CSV, logs
Word20% swapped for 35%, and on mobile addedProse, contracts, articles
Character2 to 3, 0 to 5, and the new wordsIDs, numbers, typos, URLs

A line diff tells you where something changed but not what. A word diff tells you what, which is why we prefer it for reviewing prose. For code, we stick with a line diff. Character diffs are noisy on long text but unbeatable for spotting one wrong digit in an order number.

Hard-wrapped prose makes line diffs messy, because one new word can push every following line along. Writing one sentence per line fixes that, as our Markdown diff guide explains for Git workflows.

Why Do Two Identical-Looking Texts Show Differences?

When a diff checker flags lines that look the same, the difference is almost always invisible. These are the usual suspects:

  • Line endings. Windows programs usually save CRLF (carriage return plus line feed), while macOS and Linux use LF. Every line differs by one hidden character.
  • Trailing spaces and tabs. A space at the end of a line, or a tab where the other file has four spaces.
  • A byte order mark. Some Windows editors put three invisible bytes at the start of a UTF-8 file, so only the first line differs.
  • Non-breaking spaces. Text copied from a web page or Word often contains U+00A0 instead of a normal space. Some ignore-whitespace options don't treat it as a space.
  • Smart quotes and lookalikes. Curly quotes versus straight ones, an en dash versus a hyphen, or a Cyrillic letter that looks Latin.

To compare text without spaces getting in the way, switch on the ignore-whitespace option. On the command line that's diff -w (ignore all whitespace), diff -b (ignore changes in the amount of whitespace) or diff --strip-trailing-cr for CRLF files. On Windows, fc /w squeezes runs of spaces and tabs into one and ignores them at the start and end of lines. Our text compare tool has a whitespace-normalise option for the same purpose.

Markdown files need one extra step. Pass both versions through a Markdown formatter first, so purely cosmetic choices, like the bullet character, stop showing up as edits.

How to Read Diff Output: Normal, Unified and Side-by-Side

Command-line tools print the result in one of three formats. Here are the release notes again, as two small files called old.txt and new.txt. The second file also gains a new line.

The normal format is what plain diff old.txt new.txt prints:

2c2
< Improved export speed by 20%.
---
> Improved export speed by 35% on mobile.
3a4
> Added a dark theme.

Read 2c2 as "line 2 of the first file changed into line 2 of the second". Lines starting with < come from the first file and lines starting with > come from the second. 3a4 means "after line 3, add what becomes line 4", and a d would mean a deletion.

The unified format comes from diff -u old.txt new.txt:

--- old.txt
+++ new.txt
@@ -1,4 +1,5 @@
 Release notes
-Improved export speed by 20%.
+Improved export speed by 35% on mobile.
 Fixed the login bug.
+Added a dark theme.
 Thanks to all testers.

Lines starting --- and +++ name the files (real output adds timestamps). The hunk header @@ -1,4 +1,5 @@ covers 4 lines of the old file and 5 of the new one, both starting at line 1.

In the body, a leading - marks a removed line, + an added one and a space an unchanged one. This is the same format as the unified patch you can copy from our tool. Pasting one into a GitHub comment with colour is covered in the diff block section of our Markdown diff post.

For a side-by-side format, run diff -y. Add -W 90 to set the width and -t to expand tabs:

Release notes                                  Release notes
Improved export speed by 20%.               |  Improved export speed by 35% on mobile.
Fixed the login bug.                           Fixed the login bug.
                                            >  Added a dark theme.
Thanks to all testers.                         Thanks to all testers.

A | marks a changed line, > a line only in the second file and < a line only in the first.

How to Compare Two Text Files on Windows, Mac and Linux

You don't need to install anything to compare text files. Every desktop system ships with a command for it.

Windows: fc, comp and Compare-Object

Windows 11 includes fc (file compare) and comp, both run from Command Prompt. According to Microsoft's fc documentation, these switches are the ones you'll use most:

fc old.txt new.txt
fc /c old.txt new.txt
fc /w old.txt new.txt
fc /n old.txt new.txt

The first compares line by line. /c ignores letter case, /w compresses whitespace and /n shows line numbers. fc prints each file's differing lines plus the first line that matches again. It cancels the comparison if more than 100 consecutive lines differ, so use /lb to raise that line buffer.

comp old.txt new.txt works byte by byte instead and reports the offset of each mismatch. It stops after 10 mismatches and won't compare files of different sizes unless you add /n= with a line count, which compares only the first lines of each. That makes it best for checking whether two copies are identical.

In PowerShell, fc is an alias for Format-Custom, so type fc.exe. The native PowerShell route is Compare-Object:

Compare-Object (Get-Content old.txt) (Get-Content new.txt)

It lists only the lines that differ, marked <= for the first file and => for the second, without line numbers.

macOS and Linux

Both include diff. macOS ships Apple's version, based on FreeBSD diff, and most Linux distributions use GNU diff. The flags below work in both, and the GNU diff manual page lists the rest:

diff -u old.txt new.txt
diff -q old.txt new.txt
diff -i -w old.txt new.txt
diff -B old.txt new.txt

-q only says whether the files differ, -i ignores case and -B ignores blank lines. Two more commands help with special cases. cmp old.txt new.txt reports the first differing byte and line, for example differ: char 40, line 2 (some versions print byte instead of char). When order doesn't matter, such as two email lists, sort both and use comm:

comm -3 <(sort list-a.txt) <(sort list-b.txt)

-3 hides lines found in both files. Lines only in the first file appear at the left, and lines only in the second appear indented by a tab. The <(...) syntax works in bash and zsh but not in plain sh. Git users can also run a word-level comparison on any two files, which our Markdown diff post walks through.

How Do I Compare Two Word Files?

Word has comparison built in. Open Word, go to Review > Compare and choose Compare (Word for Mac labels it Compare Documents). Pick the original under Original document and the other version under Revised document, then select OK. Per Microsoft's Compare and Merge guide, Word shows the result in a new document with the differences as tracked changes, and the two source files stay unchanged.

Google Docs works the same way. Open the primary document and choose Tools > Compare documents, then pick the other file and click Compare. Google's Compare documents help page says the result is a third document that shows the differences as suggested edits. It can also compare against a .docx file stored in Google Drive.

For a plain-text view instead of tracked changes, convert each file with our Word to Markdown converter and paste both results into the text compare tool. That converter runs on our server, takes .docx (not the older .doc), and each conversion counts toward the free daily pool of 3 server operations. PDFs work the same way through PDF to Markdown, but it reads only the text layer, and extracted lines can wrap differently from the original.

How to Use Notepad++ and VS Code to Compare Text

Notepad++ needs a plugin. Open Plugins > Plugins Admin, tick Compare or ComparePlus in the list and click Install. Then open both files in tabs and choose Compare from the plugin's submenu under Plugins.

VS Code compares without any extension. Right-click a file in the Explorer and pick Select for Compare, then right-click the second file and pick Compare with Selected. For pasted text, run File: Compare New Untitled Text Files from the Command Palette and paste one version into each side. To open a comparison from the terminal instead, see the code --diff example in our Markdown diff post.

Can ChatGPT Compare Two Documents?

It can read two versions and summarise what changed, which helps when you want to know why an edit matters. It doesn't run a diff algorithm, though. On long documents an AI assistant can skip a small change, such as one altered digit, or describe an edit that isn't there.

Use a diff checker to find the exact changes and an assistant to explain them. Before you paste confidential text into an AI chat or an online diff checker, check where it goes. Ours runs the comparison in your browser.

One limitation to know: our tool compares exactly two versions. It has no three-way merge for reconciling two people's edits against a common original, and it keeps no history between sessions.

Quick Answers on Comparing Text

A good text compare comes down to three choices: the right level (line, word or character), whether whitespace should count, and the fastest tool for where your text lives. For pasted text, open our online diff checker and paste the original on one side and the new version on the other. Switch on whitespace normalisation when spacing doesn't matter.