Text & Code Diff Checker
Compare two text snippets or code blocks side-by-side with line additions, deletions, and unified patch export.
| 1 | - | function calculateTotal(items) { | |||
| 2 | - | let total = 0; | |||
| 3 | - | for (let i = 0; i < items.length; i++) { | |||
| 4 | - | total += items[i].price; | |||
| 5 | - | } | |||
| 6 | - | return total; | |||
| 1 | + | function calculateTotal(items, taxRate = 0) { | |||
| 2 | + | const subtotal = items.reduce((sum, item) => sum + item.price, 0); | |||
| 3 | + | const tax = subtotal * taxRate; | |||
| 4 | + | return Number((subtotal + tax).toFixed(2)); | |||
| 7 | } | 5 | } |
How it works
Computes the Longest Common Subsequence (LCS) across lines and tokens purely client-side. Highlights line insertions in green and deletions in red with optional whitespace and case normalization.
Zero Telemetry: You can verify this utility's client-only execution anytime by opening your browser's Developer Tools (Network tab). No keystrokes, payloads, or clipboard contents leave your device.
Frequently asked questions
What is the difference between Side-by-Side and Unified views?
Side-by-side presents original and modified texts in parallel columns. Unified view shows a single sequential feed with +/- indicators suitable for Git patches.
Can I copy a standard Git patch?
Yes. Click "Copy Unified Patch" to generate standard diff output compatible with git apply and issue trackers.