Text Diff
Free web tool: Text Diff
About Text Diff
The Text Diff Checker is a free, browser-based tool that compares two blocks of text and highlights exactly what has changed between them. You paste an original version on the left and a modified version on the right, click Compare, and the tool produces a unified diff output showing which lines were added (highlighted in green with a + prefix) and which were removed (highlighted in red with a - prefix), along with unchanged lines for context.
Writers, developers, editors, and data analysts use text diff tools to track changes between document versions, review code snippets without a full IDE, verify that transformations preserved the right content, or simply spot unintentional edits. This tool is especially useful for comparing pasted content from different sources where visual differences are hard to spot by eye.
Technically, the comparison uses a pure JavaScript implementation of the Longest Common Subsequence (LCS) algorithm — the same fundamental algorithm used by the Unix `diff` command and version control systems like Git. The LCS table is built using dynamic programming, then backtracked to produce the sequence of added, removed, and unchanged lines. The result includes a summary count of total additions and deletions at the top of the diff panel.
Key Features
- Side-by-side input panels for original and modified text with labeled headings
- LCS (Longest Common Subsequence) algorithm for accurate line-level diff computation
- Added lines highlighted in green with a + marker for instant visual identification
- Removed lines highlighted in red with a - marker for instant visual identification
- Unchanged context lines displayed in neutral color between changed sections
- Summary counts of total added (+) and removed (-) lines shown in the diff header
- Scrollable diff output panel with monospace font for clean line alignment
- 100% client-side processing — your text content is never sent to any server
Frequently Asked Questions
What algorithm does this tool use to compute the diff?
The tool uses the Longest Common Subsequence (LCS) algorithm, implemented as a dynamic programming table. LCS finds the longest sequence of lines that appear in both texts in the same order, then classifies remaining lines as added or removed. This is the same algorithmic foundation used by the Unix `diff` command and Git.
Does this tool compare line by line or character by character?
This tool compares line by line. Each line (separated by newline characters) is treated as a single unit. If a line has even one character changed, it will appear as one removed line and one added line in the diff. For character-level granularity, you would need an inline diff tool.
What do the green and red highlights mean?
Green lines with a + prefix are lines that exist in the modified text but not in the original — these were added. Red lines with a - prefix are lines that exist in the original text but not in the modified text — these were removed. Lines with no color and a space prefix are unchanged lines present in both texts.
What does the +/- count in the diff header mean?
The diff header shows the total number of added lines (green, + count) and removed lines (red, - count) across the entire comparison. For example, "+5 / -3" means 5 lines were added and 3 lines were removed between the two versions.
Can I use this to compare code files?
Yes. Paste the contents of two code files — or two versions of the same file — into the two input panels. The monospace font in the diff output makes code comparisons particularly readable. For very large files (thousands of lines), the browser may take a moment to compute the LCS table.
Why does the diff show a line as both removed and added instead of modified?
Line-by-line diff cannot detect "modifications" — it only knows about additions and deletions. When a line changes, it appears as the original line removed (red) followed by the new line added (green). This is standard diff behavior. Tools like `git diff` with `--word-diff` provide inline character-level change highlighting.
Is whitespace-only differences detected?
Yes. The comparison is exact string matching — two lines that differ only in leading spaces, trailing spaces, or tabs will be shown as a removal and an addition. If you want to ignore whitespace differences, you would need to normalize your text before pasting (for example, by trimming lines first).
Is my text data kept private?
Yes. All diff computation runs entirely within your web browser using JavaScript. Neither the original text nor the modified text is ever transmitted to a server, stored in a database, or logged. The comparison is instant and completely private.