What is a diff checker?
A diff checker compares two versions of a text and shows what changed. This one compares line by line and shows the two versions side by side (one column on phones), highlighting the exact characters that changed within each line, so a single space or a renamed variable stands out. It also writes the changes as a unified diff, the format of diff -u that patch applies. The comparison runs in your browser, in a background thread, so large files stay responsive.
How the comparison works
The unified diff and the counts of added and removed lines come from the Myers algorithm, the one behind diff and git diff, which finds the smallest set of lines to remove and add to turn the original into the modified text. The side-by-side view, drawn by the Monaco editor, shows the changed lines next to each other and highlights the characters that changed within them, so you can see that only a word or a space changed rather than reading the whole line again.
The comparison is exact: a trailing space, a tab instead of spaces, or a changed letter case all count as changes, and spaces and tabs are shown in the editors so you can see them. Line endings aren't compared, because the editors convert the text you paste to one line ending. Long runs of unchanged lines are folded away so the changes are easy to find in a large file.
Reading a unified diff
The unified diff starts with --- original and +++ modified, then one hunk per group of changes. Each hunk header, such as @@ -1,2 +1,2 @@, gives the starting line and line count in the original and in the modified text. Lines starting with - are removed, lines starting with + are added, and lines starting with a space are unchanged context, three on each side of a change.
If a text doesn't end with a newline, its last line is followed by \ No newline at end of file, as diff writes it. To apply the diff, save it to a file and run patch with the file to change, such as patch config.yml changes.diff.
Common uses
Compare two versions of a config file to see what a deployment changed, check what edits a collaborator made to a document, or verify that a copy-pasted block matches the original. Swap sides reverses the comparison, which turns every addition into a removal and back, so you can read the change from either direction.
Line diff or word diff
This tool compares lines, which suits code, configuration, and logs, where a line is the unit of change and a patch is useful. For prose, where an edit is usually a word or two inside a long paragraph, the Text Diff tool compares word by word instead.
How to compare two texts
- 1Paste both versions. Put the original text on the left and the modified text on the right, or load the sample texts.
- 2Read the differences. Changed lines appear side by side, with the changed characters highlighted, and the counts of added and removed lines show above them. Use Swap sides to compare in the other direction.
- 3Copy the unified diff. Copy output copies the unified diff, which patch applies to the original file.
Examples
A changed line
Input
Original: color: red size: 1 Modified: color: blue size: 1
Output
--- original +++ modified @@ -1,2 +1,2 @@ -color: red +color: blue size: 1
An added line
Input
Original: a b Modified: a b c
Output
--- original +++ modified @@ -1,2 +1,3 @@ a b +c
A trailing space
Invisible in most views; highlighted here.
Input
Original: a (with a space after it) b Modified: a b
Output
--- original +++ modified @@ -1,2 +1,2 @@ -a +a b
A missing final newline
The original's last line has no newline after it.
Input
Original: a b (no newline after it) Modified: a b
Output
--- original +++ modified @@ -1,2 +1,2 @@ a -b \ No newline at end of file +b
An empty original
Input
Original: (empty) Modified: x
Output
--- original +++ modified @@ -0,0 +1 @@ +x
Unified diff markers
What each line of a unified diff means.
| Line | Meaning |
|---|---|
| --- original / +++ modified | The two texts being compared |
| @@ -1,2 +1,3 @@ | A hunk: starts at line 1 of the original (2 lines) and line 1 of the modified text (3 lines) |
| -text | Removed: only in the original |
| +text | Added: only in the modified text |
| text (a leading space) | Unchanged context |
| \ No newline at end of file | The line above has no newline after it |
Frequently asked questions
What kind of differences does it detect?
Lines that were added or removed, and within changed lines, the exact characters that differ. A changed line is a removal of the old line and an addition of the new one, shown side by side with the changed characters highlighted.
Does whitespace count?
Yes. Every space and tab counts, so a trailing space or a tab instead of spaces shows as a change, and the editors show spaces and tabs so you can see them. Line endings don't count: the editors convert pasted text to one line ending, so a Windows file and a Unix file with the same lines compare as identical.
What is a unified diff, and how do I apply it?
It's the format diff -u and git diff write: hunks of removed (-), added (+), and context lines with @@ headers. Save the copied diff to a file and apply it with patch, naming the file to change: patch config.yml changes.diff.
What does Swap sides do?
It exchanges the two texts, so the original becomes the modified text and the other way round. Every addition becomes a removal and back, which shows the change from the opposite direction.
Is there a size limit?
Only your browser's memory. The diff is computed in a background thread with the Myers algorithm, which is fast when the texts are mostly the same, and the views show only the lines on screen, so large files stay responsive.
Does it detect moved lines?
No. A line that moved appears as a removal in its old place and an addition in its new one, as in diff and git diff.
Can I compare code as well as prose?
Yes. Any plain text works: source code, config files, logs, or documents. For prose, the Text Diff tool compares word by word, which is closer to how an editor reads.
Is my text private?
Yes. Both texts stay in your browser and aren't sent to a server. The only exception is the Share link button: when you click it, it uploads both texts so the link can reopen the comparison, so don't share text that contains personal data.
Is it free?
Yes — free with no limits.