Paste two texts. Added, removed and changed lines light up side by side. Nothing is sent to a server.
1
1
Paste a text on each side. The changes show up here.
A diff is a description of how to turn one text into another. This page splits both sides into lines, then aligns them by a longest common subsequence: the longest sequence of identical lines that keeps their order. Lines that are not in that sequence are removals or additions. When a removed line is paired with an added line, the characters inside the pair are aligned the same way, so only the characters that changed are marked.
The comparison runs in your browser. It does not understand JSON, code or sentences. Two lines match only when their characters match, after line endings have been normalized.
alpha bravo charlie
alpha bravo! charlie delta
alpha and charlie are unchanged. bravo and bravo! are one replacement, and the mark sits on the added ! . delta is an added line, so it appears only on the right.
red green blue
red blue
green is a removal. The right side has no line in that row. red and blue stay aligned because they still occur in the same order.
hello
hello
A line break at the end of the text is an empty line after the last line. The two pastes above are not the same: the left one ends with a newline, the right one does not. The alignment shows that empty line as a removal.
Spaces and tabs count. Two lines that look identical in a proportional font can still differ by a trailing space. The mark is on those characters.
\r\n ) and old Mac line endings ( \r ) are turned into \n before the compare. After that, a Windows paste and a Unix paste of the same lines match. The usual way to describe a file compare is the one written up by J. W. Hunt and M. D. McIlroy in April 1976, Bell Laboratories Computing Science Technical Report 41, “An Algorithm for Differential File Comparison”. The Unix diff command comes out of that work.
Eugene W. Myers published “An O(ND) Difference Algorithm and Its Variations” in Algorithmica in 1986. GNU diff uses a variant of it. It finds a shortest edit script faster when the two texts are similar. The alignment you see here is the same kind of result, a shortest sequence of line insertions and deletions, computed from the longest common subsequence.
If the left text has n lines, the right text has m lines, and their longest common subsequence has L lines, the shortest edit script has n + m − 2L insertions and deletions. That is the count this page is built on.