Text Diff Tool Online Free
Paste two versions of any text and see every difference highlighted instantly. Line level and character level diff, side by side or unified view. Runs entirely in your browser.
How this text diff tool finds the longest common subsequence between two texts
Comparing two blocks of text for what changed is really a matching problem: find the largest set of lines that both texts share, in the same relative order, and treat everything else as added or removed. This tool solves that with a classic dynamic programming longest common subsequence algorithm, the same technique behind the Wagner-Fischer edit distance calculation, applied first to lines and then, in char mode, to individual characters within a changed line.
The comparison runs entirely in your browser against a 2D array built in JavaScript. Neither text is uploaded or logged.
The LCS algorithm, not Myers
It is worth being precise about which algorithm this is, since diff tools commonly use one of two approaches. This tool builds a full dynamic programming table, the textbook LCS method, rather than the Myers algorithm that Eugene Myers published in his 1986 paper An O(ND) Difference Algorithm and Its Variations and that tools like Git use internally.
dp[i][j] is built with one extra row and column beyond the length of each input. Every cell will hold the length of the longest common subsequence between the first i lines of text A and the first j lines of text B.
i of A equals line j of B, the cell takes the diagonal value plus one. Otherwise it takes the larger of the cell above or the cell to the left. This is standard LCS recurrence, and it runs in O(m times n) time and space, where m and n are the line counts of the two inputs.
lcs() function runs again on oldStr.split('') against newStr.split('') for any changed line, producing an inline red and green highlight inside that single line instead of just a whole line replacement.
A worked diff
Text A: “The quick fox” / “jumps over the dog” Text B: “The quick fox” / “leaps over the dog”
The first line matches exactly and is marked equal. The second line differs by one word, so LCS at the line level treats it as a full removal plus a full addition. Switch to character diff mode and the tool reruns LCS inside that pair of lines, so only jumps and leaps are highlighted rather than the entire line.
| Setting | Effect |
|---|---|
| Ignore case | Both texts are lowercased before comparison, though the original casing still displays in the output |
| Ignore whitespace | Runs of spaces and tabs collapse to one space and the line is trimmed before comparison |
| Unified view | One column, additions and removals shown inline in original document order |
| Side by side view | Two columns, with blank filler rows keeping both panes aligned |
What gets counted and shown
Stats row
Added, removed, and unchanged line counts are tallied directly from the diff array’s type field after backtracking finishes, no separate pass required.
Copy as patch
The copy button reconstructs a plain text patch using +, -, and two space prefixes per line, the same convention unified diff output uses, so it pastes cleanly into a code review comment or ticket.
- Longest common subsequence problem for the dynamic programming approach this tool implements.
- Diff for the history of the Unix utility and its output conventions.
- Eugene Myers, An O(ND) Difference Algorithm and Its Variations, 1986 for the faster algorithm most production diff tools use instead.
- Wagner-Fischer algorithm for the closely related edit distance DP formulation.
Comparisons this makes easy
Comparing two drafts of a contract to spot exactly which clauses changed, reviewing an edited blog post against the original before publishing, checking two versions of a config file line by line, catching what an editor changed in a manuscript, and verifying that a translated document still matches the structure of its source. Character mode is the one to reach for when a single word swap inside a long paragraph is what you actually need to see.
FAQ: Text Diff Tool Online Free
Yes, completely free. No account, no signup, and no payment ever required.
No. The diff algorithm runs entirely in your browser using JavaScript. Your text never leaves your device. Safe to use with confidential documents, contracts, or code.
Line level diff treats each line as one unit and marks entire lines as added or removed. Character level diff goes further and highlights the exact characters that changed within each modified line. Use character level when you need to spot small edits inside long lines.
When ignore case is on, the tool treats uppercase and lowercase letters as equal. A line that changed only in capitalization will show as unchanged. Useful when comparing text that may have been reformatted.
It collapses multiple spaces and tabs into a single space before comparing. Two lines that differ only in spacing will count as identical. Useful when comparing code that was auto-formatted or pasted from different editors.
Yes. Paste any plain text including code, JSON, YAML, SQL, HTML, or prose. The tool works on any text content.
The tool uses the Longest Common Subsequence algorithm, the same foundation used by most professional diff tools and version control systems. It finds the minimum number of changes needed to turn one text into another.
From the blog
Writing about writing tools
Readability scoring, keyword density and the rest, examined properly.