How to Compare Two Text Files and See What Changed

The fastest way to compare two text files is to paste both into a side-by-side diff tool and read the lines it highlights. Green for what was added, red for what was removed, and a changed line shows as one of each. No install, no upload, done in a few seconds.

That covers most cases. But two files that read identically on screen can still disagree byte for byte, and that is where people lose an afternoon. This guide shows the quick method, a worked example, the invisible differences worth knowing about, and where an AI chatbot like ChatGPT actually helps. If you just want the tool, our text compare page runs the whole thing in your browser.

What "comparing two text files" really means

A text file is a sequence of characters split into lines. Comparing two of them means lining up the parts that match and flagging the parts that do not. The classic tool for this is the Unix diff utility, and every modern diff viewer, including ours, does the same job with a friendlier display.

Most diff tools work line by line first. That keeps them fast on long files and matches how people read: you scan for the line that moved, then look inside it for the word that changed. Our engine is built on Google's diff-match-patch, which runs a line-mode pass before it looks at individual characters, so a thousand-line log still diffs instantly.

Ways to compare two text files

There is no single right method. It depends on where the files live and how exact you need to be.

MethodBest forExact?Effort
Reading them side by sideA few lines, one obvious editYou are the judgeLow
Online diff toolQuick checks, pasting from anywhereYes, character-exactLow
Command line (diff, git diff)Files on disk, scripting, huge filesYesMedium
Code editor (VS Code "Compare")Files already open in your editorYesLow
AI chatbot (ChatGPT)A plain-English summary of the changeNo, can miss or rewordLow

For a one-off check, a browser tool wins on speed because there is nothing to install and you can paste straight from an email, a log, or a code review. For files already tracked in a repository, git diff is right there. We will come back to the AI option, because it is genuinely useful for the right job and a trap for the wrong one.

Compare two text files in your browser, step by step

This is the routine when someone sends you two versions of a document and asks "what's different?" It takes about ten seconds.

  1. Open the text compare tool.
  2. Paste the original on the left and the new version on the right. Or use Upload to load a file straight from disk.
  3. Read the highlights. Added lines are green, removed lines are red, and a line that changed shows as a red-and-green pair.
  4. Scroll the changed lines. Inside each one, the exact words that differ are marked, so you are not rereading the whole line.
  5. If the two files look far more different than they should, jump to the invisible-differences section below.

A worked example

Say a colleague sends back an edited paragraph and asks you to check their changes. Here is your original:

The service starts at 9am on weekdays.
Refunds are processed within 14 days.
Contact [email protected] for help.

And here is their version:

The service starts at 8am on weekdays.
Refunds are processed within 30 days.
Contact [email protected] for help.
Priority support is available on request.

Drop both into the diff and the real story is short, even though it is easy to skim past in prose:

What actually changed
LineBeforeAfterChange
Start time9am8amModified
Refund window14 days30 daysModified
Support line[email protected][email protected]No change
Priority supportnonePriority support is available on request.Added

Two numbers moved and a sentence was added. The refund window doubling from 14 to 30 days is the kind of edit you want to catch before it ships, and it is a single character apart from being invisible in a quick read. That is the whole case for diffing text instead of trusting your eyes.

The invisible differences that trip people up

Sometimes a diff paints two files as completely different when they look identical on screen. The cause is almost always a character you cannot see. Here are the usual suspects.

Invisible differenceWhere it comes fromWhat to do
Line endings: CRLF vs LFOne file was saved on Windows, the other on macOS or LinuxNormalize line endings; see newline conventions
Trailing whitespaceSpaces or tabs left at the end of a lineTrim trailing whitespace, or ignore it if your tool can
A byte order mark (BOM)An editor added an invisible marker to the first lineSave as UTF-8 without a BOM
Tabs vs spacesDifferent editors or indent settingsPick one and convert; both look the same on screen
Text encodingOne file is UTF-8, the other Latin-1, so accented characters differ in bytesRe-save both as UTF-8
Non-breaking spacesPasted from a web page or a word processorFind and replace them with normal spaces

The one that bites hardest is line endings. A Windows file uses a carriage return plus a line feed (CRLF) at the end of every line; a Mac or Linux file uses just a line feed (LF). Open both in the same editor and they look the same, but every single line differs at the byte level, so a naive diff lights up like a Christmas tree. If your whole file shows as changed, check this first.

Can ChatGPT compare two files?

Yes, and a lot of people now do exactly that: paste two versions into ChatGPT (or another AI assistant) and ask "what changed?" For short files it works well and gives you something a plain diff cannot: a summary in ordinary language. "The refund window went from 14 to 30 days and a priority-support line was added" is often more useful to a busy reader than a wall of red and green.

The catch is precision. A language model is not a diff algorithm. It can miss a one-character change, quietly reword a line while summarizing, or run out of room on a long file and skip the middle. It also means handing your text to a third party, which you may not want for anything sensitive. So the two kinds of tool are complements, not rivals.

A good workflow: run the files through a deterministic diff tool first to get the exact, character-accurate list of changes, then paste that short list into an AI chatbot and ask it to explain the impact in plain language. You get the accuracy of a diff and the readability of a summary, without trusting either one to do the other's job.

Comparing files on the command line

If the files are already on disk, the built-in diff command is one line:

diff old.txt new.txt

Add -u for the unified format that Git uses, or -w to ignore whitespace differences. For files in a repository, git diff old.txt new.txt does the same with color and word-level highlighting. The browser tool is the terminal-free version of this: paste, read, done.

Related tools

Plain text is rarely the only thing you compare. If your files are structured, a format-aware view reads better: compare JSON handles reordered keys and indentation noise, and compare CSV lines up rows and columns. Cleaning up a messy list before you diff it is a job for remove duplicate lines and sort lines.

Frequently asked questions

Does comparing text files online upload them anywhere?
On comparetext.org the comparison runs in your browser. Both files are diffed by JavaScript on your own machine, so nothing is sent to a server unless you deliberately click Save or Share. That makes it safe for drafts, contracts, config, and anything else you would not want to paste into a site that uploads on every keystroke.
Why do my two text files show every line as different?
Almost always it is line endings. One file was saved on Windows (CRLF) and the other on macOS or Linux (LF), so every line differs at the byte level even though they look identical. A hidden byte order mark (BOM) on the first line or tabs versus spaces can do the same. Normalize the line endings and re-save both as UTF-8, then diff again.
Can I compare two text files without installing anything?
Yes. Open the text compare tool, paste one file on the left and the other on the right, or use Upload to load them from disk. The diff appears instantly, right in the browser, with changed lines highlighted. There is nothing to download and no account to create.
Can ChatGPT compare two files for me?
They can, and it is handy for a plain-English summary of what changed in short files. But a language model is not a diff algorithm: it can miss a small edit, reword a line while summarizing, or skip the middle of a long file. For an exact, character-accurate comparison use a diff tool, then hand the result to an AI if you want it explained in words.
How do I compare two files and ignore whitespace?
On the command line, diff -w old.txt new.txt ignores whitespace differences, and diff -b ignores changes in the amount of whitespace. In a browser, trim trailing spaces and normalize line endings before you paste, since those are the whitespace changes that most often clutter a diff. The goal is to leave only the edits that change meaning.
What is the difference between comparing text and comparing code?
The mechanics are the same: both line up matching lines and flag the rest. The difference is what counts as a real change. In prose, a reflowed paragraph can look like a big edit when only a word moved. In code, indentation and a moved function matter. A format-aware view such as JSON compare or a language-aware editor reduces that noise for structured files.

Ready to try it? Paste your two files into the text compare tool and see what changed.