ToolSphere

Text Diff & Compare

More tools

Compare two texts online: paste the original and the changed version to see added, deleted and changed lines highlighted. Free diff checker, no upload.

Paste the original and changed text to compare them line by line.

Line changes

2 added · 1 removed · 2 unchanged

A changed line counts as a removal and an addition. Spaces and letter case matter.

Whole lines are compared, including spaces. A final line break creates an extra empty line. A blank box represents one empty line when the other box contains text. Both boxes empty clears the comparison.

Compared lines

+ added in B · − removed from A · = unchanged

=Hello World
−Next.js is awesome
+Next.js is super fast
=Welcome to ToolSphere
+Enjoy your stay!

On this browser only

Give feedback

Did this tool help?

Tell us what worked, what didn’t, or what you’d like next.

Opens Google Forms in a new tab with this tool’s name filled in. No sign-in or email required. Feedback is optional.

About Text Diff & Compare

Why Diffing Uses Longest Common Subsequence, Not Just Line Matching

Comparing two versions of text to highlight what changed sounds like it should be simple line-by-line matching, but that naive approach breaks badly the moment lines are inserted or deleted in the middle of a document — every subsequent line shifts position, and a position-based comparison would flag every single line after the insertion point as "changed," even though most of them are actually identical, just shifted.

The Longest Common Subsequence (LCS) algorithm solves this correctly by finding the longest sequence of lines that appear in the same relative order in both versions (not necessarily contiguous or at the same absolute position), then identifying everything outside that shared sequence as a genuine addition or deletion — this is exactly what lets a diff tool correctly show "one line was inserted here" instead of incorrectly claiming twenty subsequent lines all changed.

This is the same underlying algorithm behind git diff and most version control change-tracking — a genuinely different (and much more useful) approach than simple side-by-side line-number comparison, which is why diff output correctly isolates a small, focused change even in a document where a large block of surrounding content shifted position as a result.

Frequently asked questions

Why can't a diff tool just compare text line-by-line at matching positions?

A single inserted or deleted line shifts every subsequent line's position — a naive positional comparison would flag all those shifted-but-otherwise-unchanged lines as different, producing a misleading, noisy diff instead of correctly isolating the actual single change.

What does "Longest Common Subsequence" actually find?

The longest sequence of lines appearing in the same relative order in both text versions, not necessarily at the same position or contiguous — everything outside that shared sequence is identified as a genuine addition or deletion, which correctly isolates real changes.

Is this the same technique used by git diff?

Yes — LCS-based comparison (or closely related algorithms) is the standard approach behind most version control diff tools, precisely because it correctly handles insertions and deletions without falsely flagging unrelated shifted content as changed.

Have a suggestion for Text Diff & Compare?Share your feedback ↗