Skip to content

Compare Text Files

Compare two pasted lists line by line. Lines a and b against lines b and c share b, leave a only in the first list, and leave c only in the second. The page does not open a file.

Result

Paste two lists

How to Use

  1. 1 Paste the first list and the second list.
  2. 2 Read the shared lines and the lines that appear on only one side.
  3. 3 a and b against b and c shares b.

Example Output

  • a b against b c shares b.

About This Tool

Blank lines are ignored. A line matches after trimming spaces. Order in each result follows the first time the line appears.

Comparing a and b with b and c

Type a on the first line of First list and b on the second line. Type b on the first line of Second list and c on the second line. The headline reads 1 shared line. The label above the headline reads Comparison. The lines under the result are Only in first 1, Only in second 1, and Shared 1. The result text has three blocks. Only in the first list shows a. Only in the second list shows c. Shared shows b. The page compares the lines you pasted. It does not open a file, read a folder, or upload a document. The steps are trim each line and drop blanks, find lines that appear in only one list, and find lines that appear in both.

A line matches after trimming spaces at its ends. The line b with spaces around it is the same line as b. Blank lines are ignored. A repeated line inside one list is kept once, at the first time it appears. Order in each result follows that first appearance. In the sample, a appears only in the first list, c appears only in the second list, and b appears in both, so the shared block is the single line b. The headline uses line when the shared count is 1, and lines when the shared count is any other number, including 0.

Each list must be from 1 to 20000 characters. An empty list, or a list longer than 20000 characters, is refused with First list must be from 1 to 20000 characters or Second list must be from 1 to 20000 characters, naming the list that failed. The button says Compare the lines. Before you submit, the waiting line is Paste two lists. Reset restores the sample lists, a then b, and b then c. Copy result copies the three blocks, including the headings Only in the first list, Only in the second list, and Shared.

Letter case matters. A and a are different lines. The sample uses lowercase a, b, and c, and the shared line is the lowercase b. The page does not sort either list. It does not join the lines into a paragraph. It does not decide which list is newer. It reports the shared lines and the lines that sit on only one side, in first-seen order, and it stops there. If you need a file from disk, paste its lines yourself. The page still will not open the file.

What a Shared Line Is

A line is the text between line breaks, after spaces at the ends are removed. Empty results of that trim are dropped, so a blank line never becomes a shared line and never becomes a one-sided line. If the same text appears twice in the first list, the second copy is dropped. The comparison then asks a simple question of each remaining line. Is this first-list line also in the second list? If it is, it is shared. If it is not, it is only in the first list. The second list is asked the matching question. A second-list line missing from the first list is only in the second list.

The headline counts shared lines only. The sample has one shared line, b, so the headline is 1 shared line. The counts underneath are separate. Only in first is 1 because of a. Only in second is 1 because of c. Shared is 1 because of b. The text blocks list the actual lines, not only the counts. When a block would be empty, the page writes (none) under that heading. The sample has a line in every block, so you will not see (none) until you change the lists. Order inside a block follows the first time that line appeared in the list that supplied it. Shared follows the first list.

How a and b Against b and c Share b

The first list trims to a, then b. The second list trims to b, then c. a is not in the second list, so the first block is a. c is not in the first list, so the second block is c. b is in both, so the shared block is b. The counts are 1, 1, and 1. The headline is 1 shared line. You can check it by eye: the only line written on both sides is b. The page does not also tell you the line number where b sat. It tells you the line text and which side lacked it. Reset returns these two lists if you want that 1 shared line again.

Removing repeats inside one paste is a different job, and it uses one box. The Remove Duplicate Lines keeps the first copy of each line. a, then a, then b becomes a and b. Blank lines are dropped. The page does not sort the lines, and it does not compare a second list. A duplicate a in the first list of this comparison is already collapsed before the sides are compared, but the other list is still required. Use the duplicate remover when you have one list and you want the first copy of each line. Use this page when you have two lists and you want a, b, and c placed in the three blocks.

Lines the Page Will Not Read from Disk

The labels say First list and Second list. They do not say choose a file. Pasting is the whole input. A path typed as a line is just a line of text. If both lists contain that same path text, it is shared. The page does not open the path. If one list contains it and the other does not, it is only on that side. The page still does not open it. There is no upload control and no folder listing. Two lists, each from 1 to 20000 characters, are the limit.

Comparisons You Can Recompute

Compare the sample and confirm the headline 1 shared line, Only in first 1, Only in second 1, Shared 1, and the blocks a, c, and b. Add a second a under the first list so the lines are a, a, and b. The extra a is dropped. The blocks stay a, c, and b, and the headline stays 1 shared line. Change the first list to A and b, and leave the second list as a and b. A and a are different lines. Only in the first list shows A. Only in the second list shows a. Shared shows b. The headline is still 1 shared line, for a different reason. Put the same two lines on both sides, a and b against a and b. Only in first is 0, only in second is 0, both blocks say (none), Shared lists a and b, and the headline is 2 shared lines.

Sorting is a different pass over one list. The Alphabetical Sorter sorts one item per line from A to Z. banana, apple, and cherry become apple, banana, and cherry. The sort ignores letter case when it compares, and it keeps the spelling you typed. It asks for 2 to 100 lines. It does not place lines into only-first, only-second, and shared. Use it when the job is order. Use this page when the job is to see that b is the shared line between a and b and b and c.

Limits of Two Pasted Lists

The comparison describes the lines present after trim and after duplicates inside each list are removed. It does not describe a file on disk, a diff of characters inside a line, or a history of edits. Two lines either match exactly after trimming or they do not. A line that differs by one letter is only on its own side. The page does not show the letter that differs. It does not align words inside the line. It does not number the rows. Shared means the whole trimmed line appeared in both lists.

Mistakes That Move a, b, or c

The common miss is to expect the page to open a file whose name you typed. It compares pasted lines only. Another miss is to expect A and a to match. They do not. Another miss is to count a repeated a as two only-first lines. The repeat is dropped, so one a remains. Another miss is to read the headline as a count of every line. 1 shared line is the shared count, not the sum of a, b, and c. The other counts are on the lines Only in first and Only in second. Another miss is to expect the blocks to be sorted. They follow first appearance. A fifth miss is to leave blank lines in the paste and expect them to count. Blank lines are dropped before the comparison.

Folding a whole paste into one line is a different cleanup. The Text Cleaner trims the ends and folds repeated spaces, tabs, and line breaks into one space. Hello followed by three spaces and world becomes Hello world, with Characters in and Characters out on the lines. It does not store the text, and it does not compare two lists. If you cleaned both lists into single lines first, this page would then compare those single lines. Use the cleaner when you want one space between words. Use this page when each item should stay on its own line and b should remain the shared line.

Using the Three Blocks

Paste the first list, paste the second list, and press Compare the lines. Read the headline, then the three counts, then the three blocks. The counts should match the number of lines in the blocks. In the sample, each count is 1 and each block has one line: a, then c, then b. If a line you expected to share appears under only one side, compare its spelling and its case with the other list. End spaces do not explain a miss, because they are trimmed. A different letter does. A blank line does not explain a miss, because it was dropped.

Reading 1 Shared Line

Read the sample in this order. The headline is 1 shared line. The label is Comparison. Only in first is 1. Only in second is 1. Shared is 1. The text shows a under Only in the first list, c under Only in the second list, and b under Shared. The steps are trim each line and drop blanks, find lines that appear in only one list, and find lines that appear in both. A refusal is not a shared count of 0. The character errors for the first list and the second list mean there are no blocks to record. A successful compare with nothing shared is different: the headline is 0 shared lines, and the shared block says (none). Write that result as a real comparison. Write an error as an error.

Reversing characters is a different record of a line. The Reverse Text Generator reverses the characters in the text you type. Hello becomes olleH. The page does not reverse the meaning of the words, and it does not compare two lists. A reversed b is not the shared b from this sample unless the other list also contains that reversed text. Use the reverser when you want the characters turned around. Use the shared block here when you want the line b that both lists already contain.

What the Blocks Do Not Decide

The blocks do not decide which list is correct, which file is newer, or which line you should keep. They decide membership after trim. You chose the first list. You chose the second list. The page dropped blanks, dropped repeats inside each list, and sorted nothing. a is only in the first list because the second list has no a. c is only in the second list because the first list has no c. b is shared because both lists have b. If you add a to the second list, a moves to Shared. The page cannot know whether that addition is what you wanted.

Checks on the Sample Comparison

Compare the sample and confirm 1 shared line, only in first a, only in second c, and shared b. Repeat a in the first list and confirm the blocks do not change. Change the first a to A and confirm A and a land on opposite sides while b stays shared. Put a and b on both sides and confirm 2 shared lines and (none) on the one-sided blocks. Clear the first list and confirm First list must be from 1 to 20000 characters. Reset and compare once more so the sample blocks are the last result.

A pace and a word total are not this comparison. The Reading Time Calculator divides a word count you type by a pace you type. 400 words at 200 words per minute is 2 minutes. It does not read a file, and it does not place lines into shared and one-sided blocks. Use it when you already know a word count and a pace. Use this page when the lists are a and b against b and c and the headline you want is 1 shared line.

Frequently Asked Questions

What is shared by a and b against b and c?

The headline is 1 shared line. a is only in the first list. c is only in the second list. b is the shared line. The counts are Only in first 1, Only in second 1, and Shared 1.

Does the page open a file?

No. It compares the two lists you paste. A path typed as a line is text. The page does not open that path, and it does not upload a document.

Does letter case matter?

Yes. A and a are different lines. If the first list is A and b and the second list is a and b, A and a are on opposite sides and b is the shared line.

What happens to blank lines and repeats?

Blank lines are dropped. A repeated line inside one list is kept once, at its first appearance. Repeating a in the first sample list does not add a second only-first line.

Are the results sorted?

No. Order follows the first time the line appears. Shared follows the first list. The page does not sort A to Z.

What if nothing is shared?

The headline is 0 shared lines and the shared block says (none). Lines that appear on only one side still show in their blocks. An empty list is refused before that result.

How long can each list be?

Each list is 1 to 20000 characters. An empty or longer list is refused with First list must be from 1 to 20000 characters or Second list must be from 1 to 20000 characters.

What does the headline count?

Shared lines only. 1 shared line is b in the sample. It is not the count of every line. Only in first and Only in second are the other counts. Copy result copies the three blocks.