“Compare these two files and tell me what changed.” If anyone has ever asked you that, you know the pain: for a short snippet you can eyeball it, but with anything longer the changes get buried and one of them is easy to miss. Developers run into this task all the time with source code, log files and configuration files.

The good news is that you do not have to hunt for changes by eye. A diff tool compares two texts automatically and shows you exactly which lines were added, removed or left untouched.

In this guide, you will learn what text comparison (a text diff) is, how diffing works, and how to find the differences between two texts — including a free online tool that runs entirely in your browser.

What Is Text Comparison (Text Diff)?

Text comparison is the task of lining up two texts and identifying what was added, what was removed and what stayed the same. In software it is usually called a diff — the same word used by the command-line diff utility and by Git.

A diff tool splits both texts line by line and matches the lines against each other. Every line is classified as either “same”, “added” or “deleted”, and the result is a compact view of everything that changed.

How a diff works

Under the hood, a diff tool follows roughly three steps.

  1. Split the texts into lines — each text is broken into a list of lines using line breaks as the separator.
  2. Align the common lines — lines that exist in both texts are matched up. Even when the positions do not line up (line 3 in A may be line 5 in B), lines with identical content are treated as the same.
  3. Flag the additions and deletions — lines that cannot be matched are shown as “added” (present only in text B) or “deleted” (present only in text A).

That is all it takes to answer “what changed between version 1 and version 2” in seconds, without reading either text in full.

What "diff" means: the word comes from the English "difference". When someone asks for "the diff", they are asking for a structured summary of what is different between two versions.

Line-based vs. character-based comparison

There are two ways to think about comparing text, depending on the unit of comparison.

Unit What is compared Strengths Good for
Line-based Whole lines Easy to read; the flow of changes is clear Code, documents, logs, configuration files
Character-based Individual characters Pinpoints exactly which characters inside a line changed Spotting a single typo or wording tweak

Line-based comparison is the standard approach for text files in general. The Tools Hub text diff tool also uses line-based comparison.

Display formats: unified and side-by-side

Diff results are usually shown in one of two formats.

Format Looks like Strengths
Unified diff One column; added lines start with +, deleted lines with - Compact and easy to paste into email or chat
Side-by-side The original and the new text in two columns Makes it intuitive to see where and how things changed

The unified format is the standard in version control systems such as Git. Saved as a .diff or .patch file, it can also be shared as “apply this file” — which is handy when handing over a set of changes.

When Text Comparison Helps

1. Reviewing code changes

After refactoring or updating code, comparing the before and after versions lets you check that only the intended parts changed. The same applies when reviewing changes made by an automated script or an AI assistant: the diff shows the scope of the change at a glance, so nothing gets missed.

2. Checking document revisions

When a contract or meeting minutes come back from the other side with edits, comparing the previous draft with the revised version reveals exactly which clauses and sentences were rewritten. Small wording changes are easy to miss when reading linearly, but a diff highlights every addition and deletion.

3. Diffing logs and configuration files

During incident investigation, comparing logs from a healthy run with logs from a failing run helps isolate “what is different”. Comparing configuration files between development and production environments is another way to catch configuration mistakes before they become problems.

Pitfalls to Watch Out For

Line endings

Windows and macOS use different line-ending codes (CRLF and LF). Two texts that look identical can be flagged as “every line changed” if only the line endings differ. When the result does not look right, first normalize both texts to the same line-ending style and compare again.

Trailing whitespace

A single space at the end of a line is enough for that line to be treated as changed. If you see a long tail of tiny differences, trailing whitespace is a common culprit.

Encoding

If the two files use different character encodings (UTF-8, Shift_JIS, and so on), you may get garbled text or a result where lines that should match do not. If the output looks garbled, check the encoding of each file first.

Size limits

Even browser-based tools have practical limits. The Tools Hub text diff tool supports up to 200,000 characters and 20,000 lines per text. Beyond that, split the text into parts and compare each part separately.

Prepare before comparing: line up the two texts in the same "unit" first — same line endings, no extra blank lines, matching encoding. The diff then shows only the changes that actually matter.

Comparing Text With a Free Online Tool

No software to install. With the Tools Hub text diff tool, you can compare two texts in your browser in a few seconds. Everything runs locally in your browser, so the text you enter is never sent to a server.

How to use it (3 steps)

1

Enter or load your texts

Open the text diff tool and paste the two texts into the input areas. You can also load text files — one file per side.

2

Press "Compare"

The diff is calculated and the tool shows how many lines were added, deleted and left unchanged. Switch between the side-by-side view and the unified (unified diff) view as needed.

3

Review and share the result

Copy the result as a unified diff or download it as a .diff file. It is ready to paste into email or chat, or to save as a patch file.

The tool featured in this guide

Text Diff Tool

Runs entirely in your browser · Free · No sign-up. Your text is never uploaded to a server.

Try it now

Key Takeaways

  • Text comparison (a text diff) pinpoints what was added, deleted or unchanged between two texts, line by line
  • The two main display formats are the unified (single column) and side-by-side (two columns) views
  • Line-based comparison fits code, documents, logs and configuration files
  • When the result looks wrong, check line endings, trailing whitespace and encoding
  • The Tools Hub text diff tool is free, requires no sign-up and never uploads your text

Turning “hunt for the difference” into “review the diff” takes one comparison. Get two texts ready and give the Tools Hub text diff tool a try.

FAQ

Is the comparison line-based or character-based?

The Tools Hub text diff tool is line-based. Each line is classified as same, added or deleted. It cannot pinpoint a single character within a line.

How long can the texts be?

Each text is limited to 200,000 characters and 20,000 lines. If your texts are longer, split them into parts and compare each part.

Can I save the diff as a file?

Yes. You can copy the result as a unified diff or download it as a .diff file, which you can share as a patch file.

Is my text uploaded to a server?

No. The whole comparison happens in your browser, and nothing you enter is transmitted.