Text Diff

Compare two texts and see the highlighted differences — by line or by word, with colored additions and removals. The calculation uses the LCS algorithm.

Granularity

What is a diff for?

A diff shows what changed between two versions of a text: which lines (or words) were added, which were removed and which stayed the same. It's the foundation of version control tools like Git and of code reviews, but it's also useful for comparing contracts, texts, configurations and any pair of similar documents.

How the comparison works

The tool uses the longest common subsequence algorithm (LCS). It finds the longest sequence of chunks that appear in the same order in both texts — these chunks are the "equal" parts. Everything left over on the Text A side is marked as removed, and everything left over on the Text B side is marked as added. This is the same mathematical principle behind classic diffs.

By line or by word

Frequently Asked Questions (FAQ)

Is there a size limit?

The LCS algorithm uses a table proportional to the product of the two texts' lengths. To avoid freezing the tab, there is a safety limit; if it's reached, the tool warns you and suggests using line mode or reducing the content.

Is the result safe if I paste code?

Yes. All compared text is inserted into the result as plain text (via textContent), never as HTML — there's no risk that pasted tags or scripts will be executed.

Does the diff show the smallest possible change?

Yes. Since it uses LCS, the number of additions and removals is the minimum necessary to transform Text A into Text B, at the chosen granularity.