Text diff
Compare two texts and highlight differences
Text 1 (Original)
4 lines, 14 words, 78 characters
Text 2 (Modified)
5 lines, 18 words, 103 characters
Differences
Line-by-line comparison of the two texts
Line 2: Modified - This is the first text. + This is the second text. Line 4: Modified - Some content here. + Different content here. Line 5: Added + And an extra line.
Legend:
- - Removed line
- + Added line
TL;DR
What is Text diff?
Text diff compares two strings and highlights the lines or characters that differ. It shows additions, deletions, and unchanged content so you can immediately see what changed between two versions of a document, config file, or code snippet.
Common use cases
- ‣Document review: compare two versions of a specification, contract, or README to see what changed
- ‣Config comparison: diff two configuration files to identify differences before deploying
- ‣Paste debugging: compare the text you pasted against the original to spot invisible characters or encoding issues
Frequently asked questions
What algorithm does text diff use?
Most diff tools use the Longest Common Subsequence (LCS) algorithm, which finds the longest sequence of lines or characters common to both inputs and marks everything else as added or removed. The classic Unix diff utility and Git diff are both based on LCS.
What is the difference between line diff and character diff?
Line diff compares whole lines and is suited for code and configuration files. Character diff compares individual characters within lines and is suited for prose or single-line values where small changes (typos, punctuation) matter.
See also
- ‣JSON diff: for structured JSON comparisons, use the dedicated JSON diff which understands object structure and ignores key ordering
- ‣Regex tester: apply a regex find-and-replace to a text, then diff the before and after to confirm only the intended characters changed