Text Compare (Diff)
Compare two text strings or code snippets line by line to visually highlight additions, deletions, and edits.
Original Text (Old)
Modified Text (New)
Text Difference Output
+3 additions-5 deletions
function calculateTotal(items) {
- let total = 0;
- for (let i = 0; i < items.length; i++) {
- total += items[i].price;
- }
- return total;
+ return items.reduce((sum, item) => {
+ return sum + (item.price * (item.quantity || 1));
+ }, 0);
}
How to Use the Text Compare (Diff)
- Paste the original text or code into the left box.
- Paste the modified version into the right box.
- Review the difference output: added lines are highlighted in green with a +, removed lines in red with a -.
- Use the addition and deletion counts to see the size of the change at a glance.
Text Compare (Diff) Features
- Original and modified text entered side by side
- Line-level difference highlighting in green and red
- Live addition and deletion counts
Frequently Asked Questions
How does the text comparison work?
The two texts are compared line by line using the widely used jsdiff library. Unchanged lines are shown as-is, while a line that was edited appears as a removed line followed by its new version.
Can I compare code files?
Yes. Indentation and whitespace are preserved, which makes the diff checker useful for reviewing code changes, configuration files, and generated output. Note that whitespace-only changes are also reported as differences.
Is my text uploaded to a server?
No. The comparison runs entirely in your browser, so contracts, drafts, and source code stay on your device.