Home โ€บ Text Diff Checker (Compare Two Texts)

Text Diff Checker (Compare Two Texts)

Unified diff

How this diff works

Both inputs are split into lines and compared with the Myers diff algorithm (Eugene Myers, 1986), which finds the shortest edit script โ€” the minimum number of line insertions and deletions that turn the original into the changed text. Lines that are only in the original are shown in red with a -, lines only in the changed text are green with a +, and unchanged lines keep their line numbers from both sides (old โ”‚ new).

The result is also given in the unified diff format used by git diff and diff -u, with @@ -a,b +c,d @@ hunk headers and 3 lines of context, so you can paste it into a code review, a ticket, or apply it with patch.

Reading a unified diff

@@ -1,6 +1,7 @@
 server {
-    listen 80;
+    listen 443 ssl;
     server_name example.com;

-1,6 means "starting at line 1 of the original, 6 lines"; +1,7 means "starting at line 1 of the new file, 7 lines". Lines starting with a space are context and unchanged.

Tips and gotchas

Frequently asked questions

How does an online diff checker decide what changed?

It searches for the longest common subsequence of lines between the two texts: the largest set of lines that appear in both, in the same order. Everything in the original that is not part of it is shown as removed, and everything in the changed text that is not part of it is shown as added. This page uses the Myers algorithm, the same family of algorithm used by git diff.

Why does a whole line show as changed when I only edited one character?

This is a line-based diff, like git diff and most code review tools: a line is either identical or different. An edited line therefore appears as one removed line followed by one added line. Enable 'Ignore whitespace' if the only differences are indentation or trailing spaces.

Can I compare JSON files with it?

Yes, but format both with the JSON Formatter first (ideally with 'Sort keys' on). Otherwise a minified JSON document is one long line and key order differences show up as changes even when the data is the same.

Is my text uploaded anywhere?

No. Both texts are compared by JavaScript on this page. Nothing is sent to a server, so you can safely compare configuration files, contracts or logs.