How it works
Lines first
Both texts are split into lines. Lines that match at the start and the end are set aside, and the middle is compared with a longest common subsequence: the largest set of lines both texts share in the same order. Everything else is a removal from the original or an addition in the changed text.
When the middle would need more than four million comparisons, its lines are shown as removed and added wholesale instead of freezing the page.
Then words
A run of removed lines followed by added lines is paired line by line. If two paired lines share at least 40% of their words, spaces and symbols, the words that differ are highlighted; lines less alike than that are left as whole changes.
The patch
Copy patch and Download give the comparison as text: unchanged lines start with two spaces, removed lines with “- ” and added lines with “+ ”.



