Skip to content

Compare Text Line by Line: Text Diff Checker

Paste the original on one side and the changed version on the other. Every line is marked as unchanged, removed or added, with a count of each.

Runs in your browserFree, no sign-upLast reviewed

Settings

Results update automatically as you type.

Differences

Added lines
2
Removed lines
2
Unchanged lines
1
Identical
No

Line by line

LineContent
−1const port = 3000;
+1const port = process.env.PORT || 3000;
=2start(port);
−3console.log('ready');
+3console.log('listening');

Quick answers

How do I compare two texts line by line?
Paste one text into Original and the other into Changed. The tool lists every line in order with a marker: = for a line found in both, a minus sign for a line only in the original and a plus sign for a line only in the changed text, plus totals for each.
How do I check if two strings are identical?
Paste one string in each box and look at the Identical figure. It reads Yes only when no line was added or removed. Untick Ignore leading/trailing spaces first if a stray space at either end of a line should count as a difference.
What do the plus and minus signs mean in a diff?
A minus sign marks a line that is in the first text but not the second, so it was removed. A plus sign marks a line that is only in the second text, so it was added. An edited line appears as a minus line followed by a plus line.
Can I compare two lines of text instead of whole files?
Yes. Put one line in each box. If they match you get one unchanged line and Identical: Yes. If they differ, the result is one removed line and one added line. Spaces at the start or end of a line are ignored by default. The tool does not highlight which characters inside the line changed.
Does a line diff detect moved lines?
Not as a move. A line that changes position is reported as removed from its old place and added at its new one. Moving the last of three lines to the top gives 1 added, 1 removed and 2 unchanged.

About Text Diff Checker

This diff checker splits two texts into lines and reports which lines are in both, which exist only in the original, and which exist only in the changed version. A line that was edited shows up as one removed line followed by one added line. Matching uses the longest common subsequence of lines, so inserting a line near the top does not throw every later line out of step. Two tick boxes control what counts as equal: Ignore letter case, and Ignore leading/trailing spaces, which is on by default so indentation changes do not flood the result. Both texts stay in your browser.

How to read the line by line comparison

MarkerMeaningNumber shown in the Line column
=The line is in both textsIts line number in Original
Minus signThe line is only in Original (removed)Its line number in Original
Plus signThe line is only in Changed (added)Its line number in Changed

Unchanged lines are printed as they appear in Original, so when case or spaces are ignored you see the original's capitalisation and indentation.

Line difference examples

Each result is what the tool reports with its default options unless stated.

One value changed in a config file

Original: timeout=30 / retries=3 / debug=false. Changed: timeout=30 / retries=5 / debug=false.

Added lines 1, Removed lines 1, Unchanged lines 2. Line 2 is listed twice: minus retries=3, then plus retries=5.

A line inserted in the middle

Original: apples / bananas / cherries. Changed: apples / blueberries / bananas / cherries.

Added lines 1, Removed lines 0, Unchanged lines 3. Only blueberries is marked with a plus; bananas and cherries still match.

A line deleted

Original: apples / bananas / cherries. Changed: apples / cherries.

Added lines 0, Removed lines 1, Unchanged lines 2. bananas is marked with a minus at line 2.

A line moved to the top

Original: one / two / three. Changed: three / one / two.

Added lines 1, Removed lines 1, Unchanged lines 2. three appears with a plus at line 1 and with a minus at line 3.

One word changed in a sentence

Original: The quick brown fox. Changed: The quick red fox.

Added lines 1, Removed lines 1, Unchanged lines 0. The whole line is shown as removed and added.

To narrow a change inside a long paragraph, break both texts into one sentence per line before comparing.

Differences in case and indentation only

Original: Hello World / (two spaces)indented. Changed: hello world / indented.

Default options: Added 1, Removed 1, Unchanged 1, Identical No. With Ignore letter case ticked as well: Unchanged 2, Identical Yes.

What the two ignore options change

SituationIgnore leading/trailing spaces onIgnore leading/trailing spaces off
Same line with different indentationEqualDifferent
Trailing spaces or tabs at the end of a lineEqualDifferent
Windows (CRLF) line endings against Unix (LF)EqualEvery line that ends in a line break differs
Two words separated by one space against two spacesDifferentDifferent
One text ends with a final line break, the other does notOne removed or added empty lineOne removed or added empty line

Ignore letter case is separate: with it ticked, Hello World and hello world are equal. Neither option changes spacing inside a line, so collapse repeated spaces first if those should not count.

How the diff decides which lines match

The tool finds the longest common subsequence of the two texts: the largest set of lines that appear in both, in the same order. Those lines are the unchanged ones. Any line of the original outside that set is reported as removed, and any line of the changed text outside it is reported as added.

This is why an insertion costs one line and not the rest of the file. A comparison that only checked line 1 against line 1 and line 2 against line 2 would mark everything after an inserted line as different.

The method builds a table with one cell for every pairing of an original line with a changed line. Two texts of 5,000 lines each need 25 million cells, so very large files can be slow in a browser tab. For those, a command-line diff is the better choice.

Command-line ways to diff lines

If the files are already on disk, these standard commands do the same job.

CommandWhat it does
diff -u old.txt new.txtUnified diff with minus and plus lines (Linux, macOS)
diff -i old.txt new.txtIgnores differences in letter case
diff -w old.txt new.txtIgnores all white space when comparing lines
git diff --no-index old.txt new.txtGit's diff for two files outside a repository
fc old.txt new.txtFile compare in the Windows command prompt
Compare-Object (Get-Content old.txt) (Get-Content new.txt)Lists differing lines in PowerShell

How to use it

  1. 1

    Paste the earlier version into Original.

  2. 2

    Paste the newer version into Changed.

  3. 3

    Keep Ignore leading/trailing spaces ticked to treat lines that differ only in indentation or trailing blanks as equal, or untick it for an exact check.

  4. 4

    Tick Ignore letter case if capitalisation should not count as a difference.

  5. 5

    Read the Differences counts, then go down the Line by line table: = is unchanged, a minus sign is a line only in Original, a plus sign is a line only in Changed.

Common questions

Can I use it to compare two versions of a script or code file?
Yes. The comparison is plain text and does not depend on the language, so it works for shell scripts, SQL, source code, JSON and configuration files. There is no syntax highlighting. For JSON or XML, format both sides the same way first so the lines break in the same places.
Does it show which characters changed inside a line?
No. The unit of comparison is the whole line. A one-character edit is reported as the old line removed and the new line added, and you compare the two by eye.
Why are all my lines marked as changed?
The usual causes are different line endings with Ignore leading/trailing spaces unticked, one text wrapped at a different width, or one side pasted as a single long line. Tick the spaces option and make sure both sides break lines in the same places.
Why does the result show an extra empty line?
A final line break creates one last empty line. If only one of the texts ends with a line break, that empty line is reported as removed or added. Delete the trailing line break, or add one to the other side.
Can I leave one box empty?
If both boxes are empty the tool asks for text. If only one is empty, the empty side is treated as a single blank line. Pasting two lines into Changed with Original empty gives Added lines 2 and Removed lines 1: the two pasted lines, plus the blank line from the empty box.
Is my text uploaded when I compare it?
No. The comparison runs in the page with JavaScript, and neither text is sent to a server. That makes it usable for configuration files and drafts you would not paste into a hosted service, though you should still follow your own organisation's rules.
Can I upload two files or compare Word and PDF documents?
No. The tool takes pasted text only. Open each file, copy its text into the two boxes and compare that. Formatting such as bold, fonts and tracked changes is not part of the comparison.
Is the order of the two boxes important?
It only decides which side is called removed and which is called added. Swap the texts and every minus becomes a plus and the reverse. The count of unchanged lines stays the same.

Looking for something else? Browse all developer tools or see every tool.