Diff Checker – Compare Text

Compare two texts line by line and see added, removed and changed lines highlighted.

Diff Checker Online: Compare Two Texts and Find the Differences

Paste the original text on the left and the new version on the right. The diff checker lines them up side by side, with line numbers for each version, and marks every line as unchanged, changed, added or removed. A summary counts each kind of change. Two options help when only real edits matter: ignore whitespace and ignore case. Both texts stay in your browser, so contracts, configuration files and source code are never uploaded.

How to compare two texts

Put the older version in the left box and the newer one in the right box; the order matters only for the labels, since text that exists only on the right is shown as added and text only on the left as removed. The comparison updates as you type, so you can paste, fix and compare again without pressing a button.

Changed lines are highlighted in amber, added lines in green and removed lines in red. Each row shows the line number in the original and in the new text, so you can jump to the same place in your editor. When a line was inserted, the left number is blank, and the following lines still line up with their counterparts instead of all showing as changed.

Original            New                   Result
alpha               alpha                 unchanged
beta                beta changed          changed
gamma               gamma                 unchanged
release             release               unchanged
                    notes                 added

How the comparison works

The checker compares line by line. It first finds the longest common subsequence of the two texts: the largest set of lines that appear in both, in the same order. Everything outside that set is an edit. A run of removed lines followed by a run of added lines is shown as changed lines side by side, which is how most people read a modification.

This is the same idea behind the Unix diff command and git diff. Git's default algorithm is Eugene Myers' O(ND) difference algorithm from 1986, which finds a shortest edit script efficiently; it also offers patience and histogram, which often group code changes more readably. For text of a normal size, all of them agree on which lines differ.

A line diff tells you which lines changed, not which words inside them. For long paragraphs, split the text into sentences or shorter lines first, or use a word-level diff such as git diff --word-diff, so that one changed comma does not mark a whole paragraph.

Ignore whitespace and ignore case

Ignore whitespace treats any run of spaces and tabs as a single space and ignores spaces at the start and end of a line. Re-indented code, trailing spaces from an editor and tabs converted to spaces stop showing up as changes. Removing a space between two words still counts, because a b and ab are different text.

Ignore case compares Error and error as equal. Use it for SQL keywords, HTML tags, headers or lists of names typed inconsistently. The original text is still displayed as you pasted it; the options only change what counts as a difference.

Line endings never count as a change: Windows CRLF and Unix LF files compare as equal, which avoids the classic case where every line of a file appears modified after it passed through a different operating system.

What people compare with a diff checker

Configuration files are the most common case: a working and a broken .env, nginx.conf or Kubernetes manifest. Sort or format both sides the same way first. For JSON, run both documents through a formatter with the same indentation, otherwise a minified file and a formatted one differ on every line.

Writers use a text compare to see what an editor changed, which clause of a contract was rewritten, or whether two versions of an article are really identical. Developers compare API responses before and after a change, SQL queries generated by an ORM, log excerpts from two runs, and lists such as package versions or exported user IDs.

Lists are the exception. If order does not matter, as with package versions, user IDs or feature flags, sort both sides first; otherwise a single entry that moved shows up as one removal and one addition.

Reading diff output from the command line

The same comparison on the command line produces a unified diff. Lines starting with a space are context, - marks a removed line and + an added one. A changed line appears as a removal followed by an addition.

$ diff -u old.txt new.txt
--- old.txt
+++ new.txt
@@ -1,4 +1,5 @@
 alpha
-beta
+beta changed
 gamma
 release
+notes

The hunk header @@ -1,4 +1,5 @@ means the hunk covers four lines starting at line 1 in the old file and five lines starting at line 1 in the new one. Useful options: -w ignores all whitespace, -b ignores changes in the amount of whitespace, -i ignores case, and git diff --no-index a.txt b.txt compares any two files, even outside a repository.

Privacy and limits

The comparison runs in JavaScript in your browser, and nothing is saved between visits: reload the page and both boxes go back to the sample text. That also means there is no history, so copy anything you want to keep.

The longest-common-subsequence step grows with the product of the two texts' lengths, so the checker handles thousands of lines comfortably. For very large inputs, where the differing part exceeds a few million line pairs, it falls back to comparing the differing lines by position. For whole directories, or files of hundreds of megabytes, use diff -r or git diff locally.

Frequently asked questions

How do I compare two texts online?

Paste the original into the left box and the new version into the right box. Changed, added and removed lines are highlighted immediately, with line numbers for both versions and a count of each type of change.

Can the diff checker ignore whitespace?

Yes. Tick Ignore whitespace to treat runs of spaces and tabs as one space and to ignore leading and trailing spaces, so re-indented or trimmed lines no longer count as changes.

Does it compare word by word?

It compares line by line and shows changed lines side by side. For long paragraphs, put each sentence on its own line first, or use git diff --word-diff for a word-level result.

Why does every line show as changed?

Usually the two texts use different formatting, such as minified versus pretty-printed JSON, or different indentation. Format both sides the same way or enable Ignore whitespace. Different line endings (CRLF and LF) are already treated as equal.

Is my text uploaded?

No. The comparison runs in your browser, and neither text is sent to a server or stored.

How do I compare two files on the command line?

Use diff -u old.txt new.txt for a unified diff, or git diff --no-index old.txt new.txt, which works outside a repository and supports --word-diff.