Ad Space
Text Diff Tool — Compare Two Texts Online
Compare two versions of a text side by side. Differences are highlighted line by line — additions in green, deletions in red, unchanged lines in grey. Useful for comparing code, documents, configs, or any text.
Frequently Asked Questions
How does the diff work?
The tool uses a Longest Common Subsequence (LCS) algorithm to find the minimum set of changes between the two texts, similar to how git diff works.
Can I compare code?
Yes. Paste any text including code. The comparison is purely text-based with no language-specific parsing.
Is whitespace-sensitive?
Yes. Spaces, tabs, and newlines are significant in the comparison. A line with a trailing space is considered different from the same line without it.
Is my text sent to a server?
No. All comparison logic runs in JavaScript in your browser.
Related Tools
Ad Space
How to compare two texts and find the differences
Comparing two texts by eye is slow and easy to get wrong. A missing comma or a changed number can hide in a long paragraph. This tool does the reading for you. It lines up both versions and marks every line that changed.
Step by step
- Paste the older version in the Original Text box.
- Paste the newer version in the Modified Text box.
- Click Compare.
- Read the result from top to bottom. Green lines were added. Red lines were removed. Grey lines are the same in both versions.
- Click Clear to start a new comparison.
If you have text files, open them in any text editor, select all, copy, then paste into the boxes.
A worked example
Say you have two versions of a short shopping list.
| Line | Original | Modified |
| 1 | Milk | Milk |
| 2 | Eggs | Eggs |
| 3 | Bread | Butter |
| 4 | Apples | Apples |
Both lists have 4 lines. Three lines are identical: Milk, Eggs and Apples. The tool shows "Bread" in red (removed) and "Butter" in green (added). That gives 1 deletion and 1 addition, and 3 unchanged lines.
Practical uses
- Documents: check what a colleague changed in a contract draft, a report or an article before you accept it.
- Code and config files: spot the one line that differs between a working file and a broken one.
- Copied content: see how much a text was reworded compared with its source.
- Lists and data: compare two exports, such as email lists or product names, line by line.
Tips for cleaner results
- Put one item per line when you can. The comparison works line by line, so a long paragraph on a single line shows up as one big change even if only one word differs.
- If everything looks different, check the line endings and indentation. Tabs versus spaces will make identical-looking lines count as changed.
- Keep the older text on the left and the newer on the right. Green then means "new" and red means "gone".
- For a long document, split it into sections and compare them one at a time. The result is easier to read.
Common questions
Why are two lines marked as different when they look the same?
The difference is probably invisible. It can be a space at the end of the line, a tab instead of spaces, or a different type of quote or dash. Retype the line in one box or remove the extra spaces, then compare again.
Does the order of the lines matter?
Yes. A line that moved to another place appears as removed in its old position and added in its new one. If you only care about which lines exist, and not their order, sort both lists alphabetically first, then compare.
Can I compare two files directly?
The tool takes pasted text, not uploaded files. Open each file in a text editor, copy the content and paste it into the two boxes. This works for plain text formats such as .txt, .csv, .json, .html or source code files.