Skip to content
ToolBoxGeniehome

Compare Two Lists

Text Tools · Added

Two lists that ought to match rarely do. Paste them side by side and this works out the intersection, each side's exclusive entries and the union — the four answers you actually want when reconciling an export against a spreadsheet.

How to use the compare two lists

  1. 1Paste the first list into the left box, one entry per line.
  2. 2Paste the second list into the right box.
  3. 3Choose how strictly to match: case, surrounding whitespace and blank lines are each yours to decide.
  4. 4Read the four result groups, and copy any one of them out.

Examples

Reconciling two short lists

Input
Left: apple, banana, cherry, banana, date · Right: banana, cherry, elderberry
Result
In both: banana, cherry. Only left: apple, date. Only right: elderberry. Union of 5. Overlap 66.7%, with a note that the left list held one repeat.

An export against a spreadsheet

Input
1,400 order references from a system export and 1,395 from a finance sheet
Result
The five references present in one and not the other, listed rather than counted — which is the part a row count never tells you.

Turn case sensitivity off when one system upper-cases its identifiers and the other does not.

About the compare two lists

Four answers, not one

The question 'do these two lists match?' almost always decomposes into four separate questions, and a yes-or-no answer is useless for all of them. What did both sides agree on? What did the first hold that the second missed? What did the second hold that the first missed? And what is the full picture once you put them together?

Those are the intersection, the two relative complements and the union. Naming them that way sounds academic until you notice that a reconciliation, a mailing-list merge and a stocktake are the same operation with different nouns attached.

Where normalisation decides the answer

Most list comparisons that produce a wrong answer produce it before any comparing happens. One system exports with a trailing space, another upper-cases its references, a third leaves a blank line at the end of the file — and suddenly two identical lists share nothing at all.

The switches on this page are deliberately explicit rather than helpfully automatic. Silently trimming and lower-casing everything would fix the common case and quietly break the one where an identifier really is case-sensitive, and you would have no way of telling which had happened.

Frequently asked questions

What happens to duplicate entries?
They are counted and reported, then set aside. Membership questions have no notion of quantity — an entry either appears in a list or it does not — so 'banana' typed twice on the left is still one member of that set. The summary tells you how many repeats each side held, so the behaviour is never a surprise.
Does the comparison respect case and spaces?
Only if you ask it to. Both are switches, because the right answer depends entirely on what the lists hold. Product codes usually want an exact match; names pasted out of two different systems usually do not. Whichever you pick, entries are displayed the way you typed them rather than in their flattened form.
How is the overlap percentage worked out?
Shared entries divided by the number of distinct entries in the shorter list — the overlap coefficient. The shorter side is the denominator because it is the only choice under which a list wholly contained in the other reads as 100%, which is usually the question being asked. It is symmetric, so swapping the boxes over changes nothing. Note that it is not the Jaccard index, which divides by the union instead and would give a lower figure whenever the two lists differ in length.
Is this the same as a diff?
No, and the distinction matters. A diff cares about order and reports the edits that turn one text into the other, which is what source control needs. This treats each side as an unordered set, so a list that has merely been re-sorted reads as an exact match here and as a wall of changes there. Reach for the text diff when sequence carries meaning.