How this calculator works
- Step 1Split into linesLine by lineEach line is compared as a whole.
- Step 2Find the longest matchMyers algorithmThe fewest removals and additions that turn one text into the other.
- Step 3Highlight the wordsInside changed linesOnly the words that differ are marked.
A diff lists the smallest set of removed and added lines that turns the original into the changed text. Lines that match stay as context.
Worked example: an edited invoice
The two invoice texts differ in 2 removed and 3 added lines; 3 lines match.
- Smallest edit
removed + added = lines in both − 2 × longest common subsequence
- Original lines5
- Changed lines6
- Lines in common, in order3
- Removed (line 3)Amount: ₹12,500
- Removed (line 4)Due: 30 days
- Added (line 3)Amount: ₹13,750
- Added (line 4)Due: 15 days
- Added (line 5)Paid by UPI
- Total edits5
Reading the result
- InlineOne listRemoved lines marked −, added lines marked +. Best on phones.
- Side by sideTwo columnsOriginal on the left, change on the right. Best for code on wide screens.
- Ignore spacingSkip changes in indentation and spaces.
- Ignore capitalsCompare wording only.
- Unified diffThe standard patch format, ready to copy or download.
- Nothing uploadedBoth texts stay on your device.
Related text tools
A diff shows what changed. Formatting first makes the real changes easier to see.
To format JSON before comparing, use the JSON formatter. The remove duplicate lines tool tidies lists, and the word counter measures each version.
Common mistakes
Mistake: Comparing files saved with different line endings.
Instead: The checker treats Windows and Unix line endings the same.
Mistake: Reading a moved paragraph as new text.
Instead: A move shows as removed in one place and added in another.
Mistake: Pasting confidential documents into online tools.
Instead: This tool runs locally, but remove secrets anyway when sharing a diff.
Read how we test our calculators, or browse more developer tools.