Hunt
Skip to content

Text Diff

Paste two versions of a text, code, configuration or prompt to see exactly what differs: lines only in one version, and changed lines with the changed words highlighted. Switch between side-by-side and unified views, ignore whitespace or case, and copy the result as a unified diff. Nothing is uploaded.

Runs in your browser

Text A

Text B

Differences

Paste text on both sides to compare them.

How the comparison works

The texts are compared line by line, finding the smallest set of lines that differ (the same approach as diff and git diff). Where lines in one text were replaced by lines in the other, they're shown as changed lines, and the words that differ within them are highlighted. Long runs of identical lines are collapsed so the differences stand out; select one to expand it, or turn on Show all lines.

Neither side is assumed to be the original: lines are labelled as only in A, only in B, or different.

How to use the Text Diff

  1. Paste one text as A and the other as B, or press Sample.
  2. Read the differences below: changed words are highlighted.
  3. Choose the side-by-side or unified view, and whether to ignore whitespace or case.
  4. Copy the result as a unified diff if you need it.

Examples

A changed line and an added line

Input
a: one
two
three
b: one
Two
three
four
Output
@@ -1,3 +1,4 @@
 one
-two
+Two
 three
+four

two and Two differ only in case: with Ignore case on, only four is reported.

Indentation changes ignored

Input
a: if (ok) {
return 1;
}
b: if (ok) {
    return 1;
}
Output

The only difference is indentation, so with Ignore whitespace on the texts are the same.

Lines far apart

Input
a: 1
2
3
4
5
6
7
8
9
10
b: 1
TWO
3
4
5
6
7
8
9
TEN
Output
@@ -1,5 +1,5 @@
 1
-2
+TWO
 3
 4
 5
@@ -7,4 +7,4 @@
 7
 8
 9
-10
+TEN

Each change gets its own @@ hunk with up to 3 lines of context around it.

Ignoring whitespace and case

Ignore whitespace treats lines as equal if they differ only in spacing: indentation, trailing spaces, or several spaces instead of one. It's useful after reformatting or when comparing text copied from different places. Ignore case treats upper and lower case as equal.

Unified diff

Copy as unified diff gives the changes in the format diff -u and git diff print: @@ headers with line numbers, then lines starting with a space (in both), - (in A) or + (in B), with 3 lines of context. It turns text A into text B; use Swap for the other direction.

Options

View
Side by side shows A and B in two columns; Unified shows one column with A's lines marked − and B's marked +.
Ignore whitespace
Treat lines that differ only in spacing as equal.
Ignore case
Treat upper and lower case as equal.
Show all lines
Show every line instead of collapsing long runs of unchanged lines.

Limitations

  • Texts are compared line by line; a moved block shows as removed in one place and added in another.
  • Very large texts (tens of thousands of lines with many differences) can take a few seconds.
  • For JSON, the JSON Diff compares data instead of text, ignoring key order and formatting.

Frequently asked questions

Are my texts uploaded?

No. The comparison runs in your browser; nothing you paste is sent anywhere.

Can I compare two files?

Yes: open each file, copy its contents and paste them as A and B. Any text works, from code and configuration files to documents and AI prompts.

Why is a line I only re-indented shown as changed?

Because its whitespace changed. Turn on Ignore whitespace to treat it as unchanged.

How do I apply the unified diff?

Save it with file headers (--- a/file and +++ b/file lines) and apply it with patch or git apply, or use it to describe the change in a review.