Text Diff
Line-level difference with simple LCS-based output and highlights.
Left
Right
How to Compare Text?
- Paste your original text in the Left text area.
- Paste the modified text in the Right text area.
- Click Compare to see line-by-line differences.
- Lines marked with "-" were removed, "+" were added, and " " are unchanged.
- Click Copy to copy the diff output.
How to Read a Line-by-Line Text Diff
When two versions of a config file, a paragraph or a list look almost the same, a diff shows exactly which lines changed. This tool splits both texts into lines, finds the longest sequence of lines they share, and prints everything else as removed or added. The comparison runs in your browser and the script makes no network requests, so your text is not uploaded.
Step by step
- Paste the older text into Left and the newer text into Right.
- Click Compare. The result appears as plain text, one line per row, and is not recalculated while you type.
- Read the first character of each row: two spaces mean the line is the same on both sides,
-means it exists only on the left, and+means it exists only on the right. - Click Copy to put the output on your clipboard.
Worked example
Left has three lines: Name: Ann, City: Oslo, Age: 30. Right has four: Name: Ann, City: Rome, Age: 30, Zip: 1. The output is:
Name: Ann(unchanged)- City: Oslo(removed)+ City: Rome(added)Age: 30(unchanged)+ Zip: 1(added)
A line that was edited shows up as one removal followed by one addition, because the tool compares whole lines and does not mark individual words.
Limits and common mistakes
- Matching is exact. A trailing space, a different capital letter or a tab instead of spaces makes two lines count as different.
- Line endings of either kind (
\nor\r\n) are accepted, so Windows and Unix files compare cleanly. - An empty line is still a line. A blank line at the end of one text shows up as a difference.
- The method builds a table with one cell per pair of lines, so extremely long inputs may be slow or use a lot of memory.
- If a block of lines was moved, it appears as removed in one place and added in another.
To check a pattern before you run a search and replace on either text, use the Regex Tester.
Frequently Asked Questions
How does the text diff tool work?
Paste two versions of text into the left and right panels and click Compare. The tool highlights additions (green), deletions (red), and unchanged lines (grey) using a line-by-line diff algorithm similar to the Unix diff command.
Can I compare code files with this tool?
Yes. The diff tool works on any plain text including code, configuration files, JSON, SQL, and documents. For best results with code, ensure consistent indentation between versions.
What is the difference between character diff and line diff?
Line diff compares entire lines and is easier to read for most content. Character diff shows changes at the character level within each line, useful for spotting subtle edits like a single changed number or spelling correction.
Can I diff two versions of a JSON file?
Yes. Paste both JSON versions and the diff highlights exactly which lines changed. For structured comparison of JSON data rather than text format, consider formatting both versions consistently before comparing.