Formula
diff = the shortest set of added and removed lines that turns the original into the changed textsimilarity = 2 × unchanged lines ÷ (lines in both texts)
- Found with a longest-common-subsequence comparison of whole lines
Lines the two texts share are kept; everything else is shown as removed or added.
Worked example
A small list
- Original text
- apple banana cherry date
- Changed text
- apple blueberry cherry date elderberry
- Show
- Changes with 2 lines of context
- Ignore whitespace differences
- No
- Ignore upper/lower case
- No
Result
2 lines added, 1 removed
Lines added: 2
Lines removed: 1
Lines unchanged: 3
apple - banana + blueberry cherry date + elderberry
How it works
A diff finds the lines the two texts have in common and marks everything else: lines only in the original are shown as removed with a minus sign, and lines only in the changed text as added with a plus sign. It uses a longest-common-subsequence comparison of whole lines, which gives a minimal list of changes.
An edited line appears as one removed line plus one added line, because the comparison works at line level. Tick the options to ignore differences in spacing or letter case when you only care about content. By default only the changed lines and two lines of context around them are shown, with … between separate groups; choose Everything to see the full text. Each side can have up to 2,500 lines.
The comparison runs in your browser and nothing is uploaded, so it is safe for configuration and code. To compare structured data, format it first with the JSON Formatter; to hash two files for a quick equality check use the Hash Generator, and for pattern matching across text try the Regex Tester.
Assumptions and limits
- Line-by-line comparison only; changes inside a line are not highlighted.
- Up to 2,500 lines per side.