Text Compare (Diff Checker)

Text compare shows exactly what changed between two versions of a document, a config file or a piece of code. Paste or open both versions and this diff checker lines them up side by side, marking removed and added lines and highlighting the individual words that changed inside each edited line.

View

+1 added−0 removed~1 changed4 unchanged

Side-by-side differences
1The quick brown fox1The quick brown fox
2Removed: jumps over the lazy dog.2Added: leaps over the lazy dog.
3Pack my box with3Pack my box with
4five dozen liquor jugs.4five dozen liquor jugs.
5Added: Sphinx of black quartz, judge my vow.
5How vexingly quick daft zebras jump!6How vexingly quick daft zebras jump!

Both texts and any files you open are compared in your browser. Nothing is uploaded.

How do you compare two texts for differences?

Put the original text on one side and the changed text on the other, and a diff tool finds the longest run of lines the two have in common, then reports everything else as removed or added. This page uses the Myers diff algorithm, the default in Git, so unchanged lines stay aligned and the list of changes is as short as possible. Edited lines are then compared word by word.

How to use the online diff checker

  1. Paste the original text on the left and the new version on the right, or use Open file or drag and drop to compare files. Files are read locally and never uploaded.
  2. Read the summary: how many lines were added, removed, changed and left unchanged.
  3. Choose Side by side to see both versions in two columns or Unified for a single column with - and + markers, like git diff.
  4. Turn on Only changed lines to fold long unchanged parts, and use Swap to reverse the direction.

Line diff and word diff

The comparison works in two passes. First the texts are split into lines and compared as sequences, which finds whole lines that were inserted or deleted. Where a deleted line and an inserted line sit at the same spot, they are treated as one changed line and compared again, word by word, so a single corrected typo is highlighted instead of the whole line.

  The quick brown fox
- jumps over the lazy dog.
+ leaps over the lazy dog.
  Pack my box with
  five dozen liquor jugs.
+ Sphinx of black quartz, judge my vow.
  How vexingly quick daft zebras jump!

The line matching uses the algorithm from Eugene Myers' paper “An O(ND) Difference Algorithm and Its Variations” (1986). It always finds a shortest edit script, so the diff shows the fewest possible changes. For two very different texts with thousands of edits, the tool falls back to marking the changed block as a whole to keep your browser responsive.

Ignore whitespace and case

Not every difference is meaningful. Re-indented code, trailing spaces or a switch from tabs to spaces can make a text difference checker light up every line. Ignore whitespace treats any run of spaces and tabs as one space and ignores spaces at the start and end of a line. Ignore case treats “Hello” and “hello” as equal. Windows (CRLF) and Unix (LF) line endings are always treated as the same, so a file saved on another system does not show as entirely changed.

Compare code, JSON and other files

Any plain text works, which makes this a quick code compare online for snippets, SQL queries or config files. For structured data, normalise both sides first so formatting differences do not hide real ones: run JSON through the JSON formatter with Sort keys on, or XML through the XML formatter, then compare the results. To find a pattern rather than a difference, use the regex tester.

For files under version control, git diff or git diff --word-diff gives the same kind of output in a terminal. This page is handy when the two versions are not in a repository, such as text from an email, two exports or a document someone sent back with edits.

Frequently asked questions

What is a diff?

A diff is a list of the differences between two versions of a text: which lines were removed, which were added and which stayed the same. The name comes from the Unix diff command, and the same idea powers code review in Git, GitHub and other version control tools.

How to compare two text?

To compare two texts, paste the original on the left and the new version on the right; the differences are highlighted immediately, with removed lines in red, added lines in green and the exact changed words marked inside edited lines. Turn on Ignore whitespace or Ignore case if those changes do not matter to you.

How to compare two files?

To compare two files, click Open file above each box (or drag a file onto it) and the contents are compared line by line in your browser without being uploaded. On the command line, diff file1 file2 on macOS and Linux, or fc file1 file2 on Windows, does the same.

How to compare two text files?

Open the first text file in the Original box and the second in the Changed box, then read the side-by-side or unified result; Only changed lines hides long unchanged stretches. Any plain text format works, including .txt, .csv, .md, .json, .xml, logs and source code.