How to use the compare two lists
- Paste your first set of items into List A, one item per line.
- Paste your second set of items into List B.
- Toggle Ignore case if capitalization should not matter, and Trim whitespace to strip extra spaces.
- Read the results immediately below: only in A, only in B, shared items and the combined union.
How the list comparer works
This list comparer applies standard set theory to your text input. Each line becomes an element in a set, meaning duplicate lines within the same list are collapsed into one entry before any math happens.
The four operations mirror Python's built-in set methods:
- A minus B (relative complement): items in A that are not in B. In Python:
setA - setB. - B minus A: items in B that are not in A. In Python:
setB - setA. - Intersection: items appearing in both lists. In Python:
setA & setB. - Union: every unique item across both lists. In Python:
setA | setB.
For example, if List A contains red, blue, green and List B contains blue, yellow, red, then A minus B is green, B minus A is yellow, the intersection is red, blue and the union is red, blue, green, yellow. When you enable "Ignore case", the tool lowercases items for matching but returns them in their original casing from List A (or List B for items unique to B).
Reference table of set operations
The table below summarizes what each operation returns when comparing two lists. Use it as a quick reference while working in this list comparison tool.
| Operation | Symbol | Python equivalent | Returns |
|---|---|---|---|
| Difference (A - B) | A \ B | A - B | Items only in A |
| Difference (B - A) | B \ A | B - A | Items only in B |
| Symmetric difference | A △ B | A ^ B | Items in A or B but not both (A-B plus B-A) |
| Intersection | A ∩ B | A & B | Items in both A and B |
| Union | A ∪ B | A | B | All unique items from A and B |
The symmetric difference is not shown as a separate output box here, but you can derive it by combining the "Only in List A" and "Only in List B" results.
Practical use cases
Comparing two lists comes up constantly in data work. Here are common scenarios where finding the list difference saves time:
- Email campaigns: paste your master subscriber list in A and your bounced addresses in B. The intersection tells you exactly who to remove.
- Inventory audits: compare the expected stock list against the counted stock to spot missing or extra items.
- Access control: check which users have permissions in system A but not system B during a migration.
- Code reviews: diff two lists of file paths or function names to see what was added or removed between versions.
If you need to reorganize your results after comparing, you can pass them through the alphabetize list tool. For converting delimited data into lines before comparing, try the csv to list converter.
Common mistakes and edge cases
Even a straightforward list comparison tool can produce surprising results if the input data is messy. Watch out for these pitfalls:
- Trailing spaces: "apple " and "apple" are different strings. Leave "Trim whitespace" enabled unless you specifically need to detect spacing errors.
- Mixed casing: "Apple" and "apple" differ by default. Enable "Ignore case" for case-insensitive matching.
- Blank lines: empty or whitespace-only lines are ignored, so a trailing newline never counts as an item.
- Duplicates within a single list: because the tool uses set logic, three copies of "cat" in List A count as one "cat". If you need frequency analysis rather than presence checks, a set-based comparer is the wrong approach.
- Unicode lookalikes: a Cyrillic "a" and a Latin "a" look identical but have different code points, so they will not match. This matters when merging data from international sources.
Verifying results with Python
You can double-check any output from this page using a short Python script. The logic matches exactly what runs in your browser:
a = set(open('a.txt').read().splitlines())b = set(open('b.txt').read().splitlines())print('A - B:', a - b)print('B - A:', b - a)print('Intersection:', a & b)print('Union:', a | b)
Save your two lists as plain text files, run the script and compare the printed sets against the results shown here. If you enabled case insensitivity on this page, add .lower() to each line when building the Python sets. This cross-verification is useful when auditing critical data like financial records or server configurations.
Worked examples
| Example | Input | Result |
|---|---|---|
| Fruits overlap | List A: Apple / Banana / Cherry / Date; List B: banana / Cherry / Fig / Grape; Ignore case: yes; Trim whitespace: yes | Only in List A (A - B): Apple Date; Only in List B (B - A): Fig Grape; In both (Intersection): Banana Cherry; All items (Union): Apple Banana Cherry Date Fig Grape |
| Numbers with duplicates | List A: 1 / 2 / 2 / 3 / 4; List B: 3 / 4 / 4 / 5 / 6; Ignore case: no; Trim whitespace: yes | Only in List A (A - B): 1 2; Only in List B (B - A): 5 6; In both (Intersection): 3 4; All items (Union): 1 2 3 4 5 6 |
| Whitespace sensitivity | List A: hello / world; List B: hello / world ; Ignore case: no; Trim whitespace: no | Only in List A (A - B): hello world; Only in List B (B - A): hello world ; In both (Intersection): (none); All items (Union): hello world hello world |
FAQ
Does this list comparer upload my data?
No. All comparisons happen locally in your browser using JavaScript. Nothing is sent to any server.
How are duplicate lines handled?
Each list is converted to a mathematical set before comparison, so duplicate lines within the same list are reduced to a single entry.
What does 'Ignore case' actually do?
It lowercases items internally to check for matches, but the output preserves the original casing from whichever list the item came from.
Can I compare more than two lists at once?
This tool handles exactly two lists. To compare three or more, run pairwise comparisons: first compare A and B, then compare the result against C.
Why do my lists show no intersection even though the words look the same?
Hidden characters like trailing spaces, tabs or non-breaking spaces make strings unequal. Enable 'Trim whitespace' or clean the data first.
Is there a limit to how many items I can compare?
There is no hard limit. Performance depends on your device, but modern browsers handle tens of thousands of lines without issue.
What is the difference between list difference and symmetric difference?
The list difference (A minus B) shows items only in A. The symmetric difference combines A minus B and B minus A, showing everything that is not shared.