How Text Diffing and Merging Works
Comparing two pieces of text to find their differences is one of the most fundamental operations in software development, document editing, and content management. Whether you are reviewing code changes, comparing contract drafts, or verifying that a configuration file was updated correctly, a diff tool shows you exactly what was added, removed, or changed between two versions.
The Diff Algorithm
This tool splits both texts into lines and computes the Longest Common Subsequence (LCS) between them. The LCS identifies the longest sequence of lines that appear in both texts in the same order, without requiring them to be contiguous. Lines that are in the original but not in the LCS are marked as removed; lines in the modified text but not in the LCS are marked as added. When a block of removed lines is immediately followed by the same number of added lines, those pairs are treated as changed lines rather than separate add/remove operations.
Interactive Merging
Unlike a simple diff viewer, this tool lets you interactively accept or reject each change. The merged result starts as a copy of the original text. When you accept a change, the modified version of that section replaces the original; when you reject it, the original is preserved. This workflow mirrors the conflict resolution process used in version control systems like Git, where developers manually decide which changes to keep after a merge conflict.
Common Use Cases
- Code review — Paste the old and new versions of a function to see exactly what changed, line by line, with color highlighting.
- Document comparison — Compare two drafts of a legal document, proposal, or article to identify edits made by a collaborator.
- Configuration auditing — Verify that only intended changes were made to a server config file, database schema, or infrastructure-as-code template.
- Content migration — When moving content between systems, compare the source and destination to confirm nothing was lost or corrupted.
- Selective merging — Cherry-pick specific changes from a modified version while keeping the rest of the original intact.
Tips for Better Diffs
For the cleanest results, normalize your text before comparing. Trailing whitespace, inconsistent line endings (CRLF vs LF), and tabs-versus-spaces can cause false positives. If you are comparing code, consider formatting both versions with the same formatter first. For prose, removing extra blank lines can reduce noise in the output.
Frequently Asked Questions
Is this tool case-sensitive?
Yes. The comparison is exact — "Hello" and "hello" will be flagged as different lines. This is important for code comparison where case matters.
Is there a size limit?
The tool runs in your browser, so it is limited by your device's memory and processing power. For most practical uses (texts up to a few thousand lines), it works instantly. Very large files (tens of thousands of lines) may cause a brief delay.