Compare contracts, config files, code or any text. Changed lines are matched up and the exact words inside them are highlighted. Everything is compared in your browser; it all stays on your device.
Line diffs are what code review tools show: fast, but a one-letter typo marks the whole line. Word diffs suit prose. Letter diffs catch a changed digit in a price, but turn a rewritten sentence into confetti. We use lines, then words inside changed lines.
Some differences can't be seen on screen. Each pair below looks the same but isn't. Reveal shows the hidden characters, and the fix is usually one of the options in the toolbar above.
Each sets the options in the toolbar above. The three with samples also load an example.
Put the old text down the side and the new text along the top. Moving right inserts a character, moving down deletes one, and a diagonal step is free wherever the two characters match. Eugene Myers' 1986 algorithm, still the default in GNU diff and git, finds a path with the fewest non-diagonal steps. It explores outwards one edit at a time, keeping only the furthest point reached on each diagonal. Edit the two strings; the path below is computed live.
Myers matches as many lines as possible, including lone braces and blank lines that happen to line up, so code edits can come out interleaved. Patience diff, by Bram Cohen, first anchors on lines that appear exactly once in both files, usually function signatures. It then diffs the gaps between them. Both run here, line by line, on the same files.
The unified format behind git diff, GitHub and code review records each change as a hunk: a header saying where it starts and how long it is, the changed lines, and a few unchanged lines of context so the patch can still be placed if the file moves a little. This is a real patch of the two texts at the top of the page. It's applied back to the original right here to prove it rebuilds the new version exactly.
N and M are the line counts of the two files, and D is the number of lines that differ. That's why diffing two nearly identical large files is fast.
diff2c2< rent £1,150---> rent £1,195The original 1974 format: ed-style commands with old and new lines.
diff -c*** 1,3 **** The Tenant! rent £1,150--- 1,3 ----! rent £1,195From BSD in 1981: both versions in full, with ! marking changed lines.
diff -u@@ -1,3 +1,3 @@ The Tenant-rent £1,150+rent £1,195Interleaves old and new in one block. Used by git, patch and code review.
git diffdiff --git a/x b/xindex 3f1a..9b2c 100644@@ -1,3 +1,3 @@Unified, plus headers for file mode, renames, copies and binary changes.
diff -e2crent £1,195.Commands an ed editor can run to turn the old file into the new one.
--minimalSpends extra time to guarantee the smallest possible diff.--patienceUses patience diff: clearer results for reordered code.--histogramPatience extended to low-frequency lines; often the best default for code.--word-diffShows changes inside lines as [-old-]{+new+}.-wIgnores all whitespace when comparing lines.--ignore-blank-linesSkips hunks that only add or remove blank lines.--color-movedColours blocks that were moved rather than changed.-MDetects renamed files by content similarity, 50% by default.Developer tools people use alongside this one.