Xerobit

List Comparer: Find Differences Between Two Lists

Paste two lists into this list comparer to see which items are unique to each list, shared by both or present in either one. It computes the list difference, list intersection and union using standard set operations, all locally in your browser without uploading anything.

Treat 'Apple' and 'apple' as the same item

Remove leading and trailing spaces from each item

Result

  • Only in List A (A - B)
    (none)

    0 items

  • Only in List B (B - A)
    (none)

    0 items

  • In both (Intersection)
    (none)

    0 items

  • All items (Union)
    (none)

    0 items

How to use the compare two lists

  1. Paste your first set of items into List A, one item per line.
  2. Paste your second set of items into List B.
  3. Toggle Ignore case if capitalization should not matter, and Trim whitespace to strip extra spaces.
  4. 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.

OperationSymbolPython equivalentReturns
Difference (A - B)A \ BA - BItems only in A
Difference (B - A)B \ AB - AItems only in B
Symmetric differenceA △ BA ^ BItems in A or B but not both (A-B plus B-A)
IntersectionA ∩ BA & BItems in both A and B
UnionA ∪ BA | BAll 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

ExampleInputResult
Fruits overlapList A: Apple / Banana / Cherry / Date; List B: banana / Cherry / Fig / Grape; Ignore case: yes; Trim whitespace: yesOnly 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 duplicatesList A: 1 / 2 / 2 / 3 / 4; List B: 3 / 4 / 4 / 5 / 6; Ignore case: no; Trim whitespace: yesOnly 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 sensitivityList A: hello / world; List B: hello / world ; Ignore case: no; Trim whitespace: noOnly 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.