The short answer. Paste both lists into the compare tool — you get four answers at once: in both, in A only, in B only, the union. In Excel, =COUNTIF(B:B, A1) tells you whether each A value exists in B. In Google Sheets, the same formula plus =FILTER(A:A, NOT(COUNTIF(B:B, A:A))) to extract the "in A only" set. On the command line, comm on two sorted files gives intersect / A-only / B-only in three columns; diff shows line-by-line differences. In Python, two set() calls and intersection / difference operators.
Four questions, one comparison
Any time you have two lists, four questions tend to come up:
- Intersect — what's in both? (Subscribers in both campaigns; files in both folders.)
- A-only — what's in A but not B? (Subscribers who unsubscribed; files that were deleted.)
- B-only — what's in B but not A? (New subscribers; new files.)
- Union — the combined deduplicated set.
Spreadsheet methods usually answer one at a time and need a fresh formula for each. Command-line and browser methods can return all four in a single pass, which is why they tend to be faster for "I just want to see what changed" questions.
Before any comparison, decide three things:
- Case-sensitive? Is Alice the same as alice?
- Trim whitespace? Is "alice " (trailing space) the same as "alice"? Almost always yes in practice; tools that don't trim by default cause a lot of false mismatches.
- Dedupe within each list? If alice appears twice in list A, do you count it as one item or two?
How do you compare two lists online, instantly?
Open the compare tool. Paste list A into the left box, list B into the middle. Four tabs on the right show the four answers:
- IN BOTH — the intersection.
- A ONLY — in A, missing from B.
- B ONLY — in B, missing from A.
- UNION — everything in either list, with duplicates collapsed.
Three toggles control the comparison semantics:
- Trim — leading and trailing whitespace per line is stripped before comparison. On by default.
- Case-sensitive — off by default, so Alice and alice match. Diacritics are normalised too — café and cafe match unless case-sensitive is on.
- Dedupe — duplicates within each input list are collapsed before comparison. On by default.
All four results update live as you edit either list. Nothing uploads — it's a few Set operations in the browser. Open DevTools → Network to confirm.
How do you compare two lists in Excel?
Excel has good single-question answers, less so for the four-at-once view.
Is each item in A also in B?
=COUNTIF(B:B, A1)
Returns the count of B-cells matching A1. Greater than zero means "yes, it's there". Wrap in a friendlier check:
=IF(COUNTIF(B:B, A1) > 0, "in both", "A only")
Fill down. To extract just the "A only" items in a fresh column on modern Excel:
=FILTER(A2:A100, COUNTIF(B:B, A2:A100) = 0)
The FILTER function only exists in Excel 365 and 2021. For older versions, sort the A-status column and copy the "A only" rows manually.
For the intersection (in both):
=FILTER(A2:A100, COUNTIF(B:B, A2:A100) > 0)
For "B only" — same idea, swapping the roles of A and B:
=FILTER(B2:B100, COUNTIF(A:A, B2:B100) = 0)
For the deduplicated union:
=UNIQUE(VSTACK(A2:A100, B2:B100))
VSTACK stacks the two ranges vertically; UNIQUE dedupes. Both are modern Excel features — on older versions, copy both columns into one, sort, then Data → Remove Duplicates.
How do you compare two lists in Google Sheets?
Identical to modern Excel — the formulas work the same way:
=FILTER(A2:A100, COUNTIF(B:B, A2:A100) = 0) // A only
=FILTER(A2:A100, COUNTIF(B:B, A2:A100) > 0) // in both
=UNIQUE({A2:A100; B2:B100}) // union
Sheets uses {...; ...} instead of VSTACK for the vertical stack. Otherwise the recipes carry over.
How do you compare two lists on the command line?
Two classic tools cover the case cleanly.
comm — intersect, A-only, B-only in one pass. Requires both files to be sorted first.
sort a.txt > a-sorted.txt
sort b.txt > b-sorted.txt
comm a-sorted.txt b-sorted.txt
Output is three columns: lines only in A, lines only in B, lines in both. The flags -1, -2, -3 hide each column — so comm -23 a-sorted.txt b-sorted.txt shows only "lines in A not in B" (column 1, with columns 2 and 3 hidden). Mnemonic: the number says which column you're hiding.
diff — line-by-line differences with context. Doesn't require sorted input.
diff a.txt b.txt
Output shows additions, deletions, and changed lines. Useful when you care about the order or position of changes; less useful when you just want set membership.
On Windows in PowerShell:
Compare-Object (Get-Content a.txt) (Get-Content b.txt)
Output shows each unique line and a SideIndicator column: <= for "only in A", => for "only in B". For just the intersect: Compare-Object ... -IncludeEqual -ExcludeDifferent.
How do you compare two lists in Python?
When the comparison is part of a script or pipeline, sets are the right primitive.
with open("a.txt") as f: a = set(line.strip() for line in f if line.strip())
with open("b.txt") as f: b = set(line.strip() for line in f if line.strip())
both = a & b # intersect
a_only = a - b
b_only = b - a
union = a | b
Three operators — & for intersect, - for difference, | for union — cover all four answers in four lines. Add .lower() on the comprehension if you want case-insensitive matching.
Which method should you use?
| Your situation | Best method |
|---|---|
| Two pasted lists, want all four answers fast | Browser tool |
| Two Excel columns, want one answer at a time | COUNTIF + FILTER |
| Two files on disk, scripted | comm on sorted input |
| Line-by-line diff with position / context | diff or a diff viewer (VS Code, Beyond Compare) |
| Python pipeline or repeatable script | set operators |
| Comparing more than two lists | Pairwise: A vs B, then result vs C, etc. |
| Case-insensitive comparison | Browser tool default, or sort -f + comm |
| Sensitive data | Browser tool or local command line — never an upload site |
Frequently asked questions
What if my lists have different formatting (extra spaces, capitalization)?
Three defenses. (1) The browser tool trims and ignores case by default, so most cosmetic differences vanish. (2) On the command line, normalise first: tr 'A-Z' 'a-z' < a.txt | sort -u > a-norm.txt. (3) In Excel, wrap your values in TRIM(LOWER(A1)) before comparing. The biggest source of false mismatches is invisible whitespace — trailing spaces, tabs, or non-breaking spaces pasted from Word.
How do I compare two CSV files by a specific column?
That's a join, not a list comparison. The cleanest paths are SQL (load both into SQLite and run a LEFT JOIN) or pandas (pd.merge(a, b, on="email", how="outer", indicator=True)). For a one-off, extract the column you care about from each file (Excel, cut -d, -f3 a.csv, or a quick spreadsheet copy) and compare those as plain lists.
Why doesn't comm work on my unsorted files?
Because comm assumes sorted input and reports phantom differences when it isn't. Always pipe through sort first: comm <(sort a.txt) <(sort b.txt) on bash, or sort to temp files. diff doesn't have this restriction; it's the right tool for unsorted input or when order matters.
How do I find duplicates within a single list?
That's not a two-list comparison — it's a duplicate finder. sort file.txt | uniq -d on the command line. In Excel, Home → Conditional Formatting → Highlight Cells Rules → Duplicate Values. The list alphabetizer with Dedupe off shows duplicates inline; for a list of only the duplicates, a quick sort | uniq -d is fastest.
Can I compare two lists with a tolerance (fuzzy match)?
Set operations are exact-match only. For fuzzy comparisons — say, "Alice Smith" vs "Smith, Alice" or typo tolerance — you need a fuzzy-matching library (Python's fuzzywuzzy / rapidfuzz, or Excel's add-in route). The browser tool doesn't do fuzzy matching, and we don't plan to add it — the implementation choices (Levenshtein, Jaro-Winkler, token sort, etc.) each have different trade-offs and the right pick depends on the data.
Is it safe to paste sensitive lists into an online comparison tool?
Only if the tool runs entirely in the browser. Open DevTools → Network, paste both lists, switch tabs, and watch for outbound requests. If you see one carrying your data, the page sent it to a server. The joinlines compare tool makes zero requests after page load — verifiable in DevTools, every time.
— the joinlines team, 2026-04-04