List Union vs. Intersection Explained

Union and intersection are the two core operations when you compare lists. The terms come from set theory, but you don't need any math background to use them. You just need to know which one gives you the answer you're actually looking for.

Quick answer

Union combines both lists into one list of every unique item, with duplicates removed. Intersection keeps only the items that appear in both lists. The union is always the same size or larger than either original list; the intersection is always the same size or smaller. Use a Compare Lists tool's union output to merge lists, and its intersection output to find what two lists have in common.

Try the operations on your own lists.

Open Compare Tool →

Intersection: what's in both lists

The intersection of two lists is everything that appears in both. An item has to be in List A and List B to make it into the intersection. If it's in only one of them, it doesn't qualify.

Take these two lists:

List A

apple

banana

cherry

date

List B

banana

date

elderberry

fig

The intersection is banana, date. Those are the only two items that appear in both lists.

When to use intersection:

  • Customers who appear in both your old and new CRM exports
  • Products stocked by both of your suppliers
  • Email addresses on both your active list and your unsubscribe list (remove these)
  • Keywords your site and a competitor both rank for

Union: everything from either list

The union of two lists is every unique item from either list. If something appears in List A, in List B, or in both, it appears exactly once in the union.

Using the same lists above, the union is:

apple, banana, cherry, date, elderberry, fig

The important thing: union is not just "combine both lists." It's combine and deduplicate. If both lists contain "banana", the union has it once. If you want raw concatenation without deduplication, that's a stack operation, which the Merge Lists tool handles.

When to use union:

  • Merging two keyword lists without duplicates
  • Combining two team rosters into one complete roster
  • Building a master list from multiple data sources
  • Deduplicating two different exports of the same underlying dataset

A Only and B Only: what changed

These two outputs get less attention but are often the most useful. They show you the parts of each list that don't overlap.

  • A Only: items in List A that aren't in List B. In the example above: apple, cherry.
  • B Only: items in List B that aren't in List A. In the example above: elderberry, fig.

In code, A Only and B Only are set differences. In Python that's set(a) - set(b) and set(b) - set(a); difference between two lists in Python walks through it, including how to keep the original order.

Together, A Only and B Only tell you what changed between two versions of a dataset. The intersection tells you what stayed the same. This is the most common pattern: compare this month's customer list against last month's, and A Only gives you who dropped off while B Only gives you who's new.

A visual way to think about it

Picture two overlapping circles. The overlap in the middle is the intersection. Everything inside either circle is the union. The part of the left circle that doesn't overlap is A Only. The part of the right circle that doesn't overlap is B Only.

The Multi-List Compare tool draws this diagram interactively when you're comparing 2 to 5 lists at once. You can click regions to filter results by which lists they appear in.

More than two lists

With three or more lists, the same concepts apply. The intersection is items that appear in every list. The union is items that appear in any list. In between, there are items that appear in some lists but not all.

The Multi-List Compare tool handles this case directly. It breaks down all the overlap regions: in all three, in exactly two (and which two), in exactly one. It also draws the Venn diagram so you can see the structure at a glance.

Comparing more than two lists?

Multi-List Compare handles 3 to 8 lists, with a live Venn diagram.

Try Multi-List Compare →

Frequently Asked Questions

What's the difference between list union and intersection?
Union combines everything from both lists into one deduplicated list. Intersection keeps only the items both lists share. If two lists have 10 total unique items and 4 of them overlap, the union has all 10 items and the intersection has just those 4.
What is the intersection of two lists?
The intersection contains every item that appears in both lists. If 'banana' is in List A and List B, it's in the intersection. If it's only in one of them, it's not.
What is the union of two lists?
The union contains every unique item from either list, without duplicates. If 'banana' appears in both lists, it still appears just once in the union.
What's the difference between union and just combining two lists?
Union deduplicates. Stacking (combining) doesn't. If both lists have 'banana', stacking gives you two instances. Union gives you one. Use the Merge Lists tool if you want to combine without deduplication.
What does 'A Only' mean in list comparison?
A Only is every item in List A that doesn't appear in List B. The formal name is the relative complement. Practically: what's in your first list that isn't in your second.
What if my lists have duplicate items within them?
Duplicates within a single list are collapsed to one item before the comparison runs. 'apple, apple, banana' in List A is treated as 'apple, banana' for set operation purposes.
Is this the same as SQL INTERSECT and UNION?
Same concept, yes. SQL's INTERSECT and UNION work on rows the same way this tool works on lines. SQL UNION deduplicates. SQL UNION ALL keeps duplicates (like stacking without dedup).
How do I find items in exactly two of three lists?
Use the Multi-List Compare tool. It breaks down all the regional overlaps: in all three lists, in exactly two (and which two), and in exactly one.
What's the opposite of an intersection?
Everything that's not in both lists. That's A Only plus B Only combined. The items that don't overlap. Useful for finding what changed or what's missing.

Share this tool

Featured on ToolDirs
© 2026 ListDiff

Free online list and text processing tools.