Subtract one list from another

Subtract one list from another (`A - B`) by removing every item from List A that also appears in List B. List A's original order is preserved, and duplicates within A are kept (only items matching something in B are removed). Paste both lists separated by `#`-prefixed header lines.

Input
Ready
Output
Live

Set difference with A's duplicates preserved

The op walks every item of List A in order and emits it unless its value appears anywhere in List B. Membership in B is checked via a Set built from B's items - not a count-based comparison, so B's internal duplicates are irrelevant.

Case sensitive off (default) means `Apple` in A matches `apple` in B and gets removed. Toggle on for exact-case matching. No trim option - whitespace differences are preserved on both sides.

Not commutative - swap the two blocks to compute `B - A` instead. For the symmetric difference (items unique to EITHER list), use Compare two lists in tagged mode.

How to use subtract one list from another

  1. 1Input your first list
  2. 2Input your second list
  3. 3Toggle 'Case sensitive' if needed
  4. 4Observe the live output update
  5. 5Copy or download the result

Keyboard shortcuts

Drive ListShift without touching the mouse.

Shortcut Action
Ctrl ZUndo last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor
EscExit fullscreen
Ctrl KOpen the command palette to jump to any tool
Ctrl SSave current pipeline draft Plus
Ctrl PRun a saved pipeline Plus

What this tool actually does

One-way set subtraction: `A \ B` with A's order preserved.

Order-preserving filter

Walks List A in order; emits each item unless its value appears anywhere in List B. No sorting. Line-for-line faithful to A's layout.

Keeps A's internal duplicates

If `apple` appears twice in A and not in B, both copies survive. Duplicate-awareness is about matching against B, not deduping A. To dedupe, chain Dedupe.

Case-insensitive by default

`Apple` in A matches `apple` in B and gets removed. Toggle Case sensitive on for exact matching.

B is a filter set, not a deletion count

If B contains `apple` once and A contains `apple` three times, all three are removed (not just one). Comparison is set-membership.

Not commutative

`A - B` differs from `B - A`. Swap the blocks to get the other direction, or use Compare two lists with Only in B mode.

Worked example

Subtract items from one list using default settings.

Input
# List 1
apple
banana
orange

# List 2
banana
orange
Output
apple

Settings reference

Understand how each option affects the output using the sample above.

Setting What it does Effect on the sample
Case sensitive: off (default) `Apple` in A matches `apple` in B Sample is all lowercase - output `apple` (banana + orange removed)
Case sensitive: on Exact-case membership check If A had `Banana` and B had `banana`, `Banana` would survive
Single block (no `# List` header) Returns empty output Status bar: "Paste two lists separated by `# List X` headers"
B is empty, A has items Nothing to subtract - A emitted unchanged A's order and duplicates preserved

FAQ

How does the 'Case sensitive' option work?
It treats uppercase and lowercase letters as different, affecting which items are considered unique.
Can I subtract more than two lists?
Currently, the tool supports subtracting two lists. For multiple lists, repeat the process iteratively.
Does this tool store my data?
No, all operations are performed in your browser, ensuring your data remains private and secure.
What formats are supported for downloading?
You can download the results as a plain text file, maintaining simplicity and compatibility.
Is there a limit to the number of items I can process?
The tool is designed to handle typical list sizes efficiently, but performance may vary with very large datasets.