Text Diff Tool Online Free

📝 Text Tools ✔ Free Forever

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.

✔ Line level diff ✔ Character level diff ✔ Side by side view ✔ Unified view ✔ 100% browser-based
View
Compare
Original Text (A)
Modified Text (B)
About This Tool

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.

Step 1 Build the table A grid 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.
Step 2 Fill it If line 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.
Step 3 Backtrack Starting from the bottom right corner, the tool walks backward: equal lines are marked equal and both pointers move diagonally, otherwise it steps toward whichever neighboring cell has the larger value, marking a removal or addition depending on which direction it took.
Step 4 Reuse for characters In character diff mode, the exact same 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.
// the LCS backtrack, unchanged from the tool source while(i > 0 ? j > 0 : false){ if(a[i-1] === b[j-1]){ result.unshift({type:‘equal’, val:a[i-1]}); i–; j–; } else if(dp[i-1][j] > dp[i][j-1]){ result.unshift({type:‘remove’, val:a[i-1]}); i–; } else { result.unshift({type:‘add’, val:b[j-1]}); j–; } }

A worked diff

Text A: “The quick fox” / “jumps over the dog”   Text B: “The quick fox” / “leaps over the dog”

The quick fox – jumps over the dog + 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.

SettingEffect
Ignore caseBoth texts are lowercased before comparison, though the original casing still displays in the output
Ignore whitespaceRuns of spaces and tabs collapse to one space and the line is trimmed before comparison
Unified viewOne column, additions and removals shown inline in original document order
Side by side viewTwo columns, with blank filler rows keeping both panes aligned
O(m times n) time and space adds up fast. A full DP table for two 5,000 line files means 25 million cells. This is exactly why production tools like Git default to the Myers algorithm, which typically runs closer to O((m+n)D) where D is the number of differences, much faster when two files are mostly similar. For the line and paragraph length comparisons this tool is built for, the straightforward LCS table is simpler to reason about and plenty fast; it is not the algorithm you would reach for to diff entire repositories.

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.

Line level LCS diff Character level LCS diff Unified and side by side views Case and whitespace ignoring

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.

Common Questions

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.

Privacy Overview

Cookies let this site remember your preferences and show us which tools people actually use. Full detail sits in our Privacy Policy.