Text Diff
Compare two blocks of text line by line and see what was added and removed. The comparison runs in your browser and highlights every change.
Comparison is line based: a paragraph rewritten in one long line appears as one removed line and one added line.
Differences
Compared output
—
Removed lines start with -, added lines with +, and matching lines have no marker.
How to read the output
| Marker | Background | Meaning |
|---|---|---|
- line | pink row | Present in the original, absent from the modified text |
+ line | green row | Present in the modified text, absent from the original |
line | grey row | Identical in both versions |
Unchanged lines are kept in the output so you can see where a change sits in the document, not only what changed.
Comparing two versions is a sequence problem
A diff does not ask "are these texts different". It finds the largest set of lines they share, keeps those in order, and reports everything else as removed or added.
How line-by-line comparison works
The algorithm builds a table of the longest common subsequence (LCS) between the two lists of lines. For every pair of positions it records how many lines can still be matched if the comparison starts there. The table is then walked backwards to produce the edit script: a line that exists in both versions is kept, and a line that cannot be matched is marked as removed or added.
diff(A, B) = keep the LCS, report A \ LCS as removed and B \ LCS as added
The result is a sequence of operations rather than two independent lists, which is why the output can interleave -, + and unchanged lines in the order they appear. Two texts of m and n lines produce a table with (m + 1) × (n + 1) cells, so both time and memory grow with the product of the lengths.
That cost is invisible for a page of prose and noticeable for two large logs. If a comparison seems slow, reduce the input to the section that matters instead of pasting entire files.
What a line diff can and cannot show
| Situation | What you see |
|---|---|
| One word changed inside a line | The whole line appears as one removal and one addition |
| A line inserted | A single green line with a + marker |
| A line deleted | A single pink line with a - marker |
| A block moved | The block is removed in one place and added in another |
| Trailing spaces changed | A difference, even though the text looks identical |
| Line endings changed | Every line can appear different if the split differs |
Line, word and character granularity
Line granularity is the right default for prose, configuration files and changelogs, because it keeps the surrounding context readable. It is coarse for a single long paragraph: one comma changed marks the entire line.
Word and character diffs solve that by comparing smaller units, at the cost of a much noisier output. A useful compromise is to break the text into one sentence or one clause per line before comparing. The diff then points at the sentence that changed, and the reader can see the exact wording without a wall of highlighted characters.
Preparing text for a clean comparison
- Use one sentence or one bullet per line. Short lines localize changes and make the output easier to scan.
- Normalize line endings. A file saved with CRLF and one saved with LF can differ on every line when read by a tool that keeps the carriage return.
- Trim trailing spaces. Editors sometimes add them silently, and they count as a change.
- Remove volatile fields. Timestamps, build numbers and generated IDs create noise that hides the real edit.
- Sort lists before comparing. A reordered list produces a large diff even when the items are the same set.
If the two versions come from different systems, check the character encoding first. The same accented word can arrive as one code point or as a base letter plus a combining mark, and the two forms compare as different strings even though they render identically.
Practical uses for a text diff
| Task | What to compare | What to look for |
|---|---|---|
| Contract review | Two revisions of the same clause list | Wording that changes an obligation |
| Configuration change | Old and new config text | Accidental deletions and altered values |
| Translation QA | Source and translated segments | Missing lines and untranslated fragments |
| Copy editing | Draft and edited version | Meaning changes hidden among style edits |
| Data export check | Two exports of the same query | Rows added, removed or reordered |
| Documentation update | Previous and current help page | Steps that no longer match the product |
In every case the value is the same: the diff narrows attention to the lines that changed, so a reviewer spends time on the edit instead of re-reading the whole document.
Limitations to keep in mind
- No intra-line highlighting. A one-character edit marks the entire line, so you still have to look closely at long lines.
- No ignore-whitespace option. Indentation and trailing spaces count as differences here. Normalize them before pasting if they are noise.
- Tie-breaking can vary. When several equally long common subsequences exist, different tools may choose a different one, producing a different but still valid diff layout.
- No three-way merge. This is a two-version comparison; reconciling three documents needs a merge tool.
- Large inputs get slow. The table grows with the product of the line counts, so split very large files before comparing.
None of these limits matter for the common case of two paragraphs or two short lists. They matter when the diff is part of a release process, where a missed line can ship a bug.
Related Text & Writing Tools
| Tool | What does it do? | Action |
|---|---|---|
| Text Character Counter & Word Counter | Free text counter: count characters with and without spaces, words and sentences, and estimate reading time. Check social media and SEO limits instantly. | Count Text → |
| Case | Convert your text between uppercase, lowercase, title case, and sentence case instantly. The perfect tool for students, secretaries, and writers. | Change Case → |
| Instagram & TikTok Line Breaker | Add clean line breaks to your Instagram and TikTok captions. Our space fixer tool inserts invisible characters to keep your formatting perfect and professional. | Line Breaks → |
| JSON Formatter & Validator | Format, validate, and minify JSON quickly and for free. Perfect for developers, API testers, and data analysts looking to prettify JSON or check syntax errors. | Format JSON → |
| AI Prompt Optimizer | Optimize your prompts for any AI model. Transform basic prompts into effective, structured inputs for ChatGPT, Claude, Gemini, Llama and more. Free and easy. | Prompt Helper → |
| Lorem Ipsum Generator | Generate placeholder paragraphs, sentences or words for layouts and mockups. | Lorem Text → |
Frequently Asked Questions
Hello and hello are different lines. To compare case-insensitively, convert both texts to the same case with a case converter before pasting them here.
Rate this Tool
Based on 0 user ratings.