Text diff

Compare two pieces of text line by line. Added lines are green, removed lines are red.

How text diff works

This tool compares two blocks of text and highlights the differences line by line. It implements a diff algorithm based on the longest common subsequence (LCS) approach — the same fundamental algorithm used by git diff and Unix diff. Lines present only in the first text are shown in red (deletions), lines present only in the second are shown in green (additions), and shared lines are shown without highlighting.

Text diff is useful for comparing document revisions, checking what changed between two versions of code or configuration, spotting differences in translated content, and verifying data exports. The line-by-line approach works best for structured content like code, CSV data, and prose with line breaks. For character-level diffing within lines (showing exactly which words or characters changed), more specialised tools are needed. All processing is browser-side — paste sensitive documents without concern about server transmission.

Frequently asked questions

What is a text diff?

A text diff is a comparison of two text blocks that highlights what was added, removed, or changed between them. Lines shown in green are additions (present in the second text only); lines in red are deletions (present in the first text only); unchanged lines are shown without colour.

How is the diff computed?

The diff uses a longest common subsequence (LCS) algorithm to find the maximum set of lines shared between both texts. Lines not in the LCS are classified as additions or deletions. This is the same approach used by git diff and Unix diff utilities.

Can I diff code with this tool?

Yes. Any text — code, configuration files, documentation, email drafts — can be compared. For code, paste the old version in the left box and the new version in the right box. Line numbers are shown for easy reference.

Is there a size limit on inputs?

No server-side limit — diffing runs entirely in your browser. Performance may slow for very large inputs (tens of thousands of lines), but typical document comparisons are processed instantly.

Related tools

Remove duplicates → Word counter → Case converter →