Find common lines in two texts

Find common lines returns every line that appears in both text A and text B. Paste both lists into the input pane separated by a line of ---; the tool builds a set from text A and walks text B, keeping any line that exists in the set. Order follows text B. The match runs in your browser; nothing uploads. For lines unique to one side see find unique lines.

Input
Line 1:1 LF cloud_done Saved locally
Result Find Common Lines
0 lines 0 chars

Set intersection on lines

Find common lines treats each text as a list of lines and computes the intersection. The split point is a line containing exactly ---. Lines from text A are loaded into a JavaScript Set, then text B is walked line by line; any line that exists in the set is emitted to the output. Duplicates inside text B survive the filter, so a line that appears twice in B and once in A appears twice in the result.

Matching is exact: case, whitespace, and trailing spaces all count. Hello and hello are treated as different lines, and foo versus foo  (with a trailing space) will not match. Strip whitespace beforehand with trim whitespace if you want to ignore margin spaces.

Output preserves the order in text B, not text A. That makes the tool useful for "filter list B down to entries that also appear in list A" workflows. For the opposite operation see find unique lines; for word-level overlap see word set intersection.

How to use find common lines in two texts

  1. 1Paste list A into the input panel, then a line with ---, then list B.
  2. 2The output panel shows every line from B that also appears in A, in the order B presented them.
  3. 3Click Copy to copy the result, or Download to save as .txt.
  4. 4Swap A and B around the separator to keep the order from the other side.
  5. 5Pre-clean lines with trim whitespace if trailing spaces are blocking matches.

Keyboard shortcuts

Drive TextResult without touching the mouse.

Shortcut Action
Ctrl FOpen the find & replace panel inside the input Plus
Ctrl ZUndo the last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor Plus
EscClose find & replace, or exit fullscreen
Ctrl KOpen the command palette to jump to any tool Plus
Ctrl SSave current workflow draft Plus
Ctrl PRun a saved workflow Plus

How the intersection works

Set membership lookup

Lines from text A are loaded into a JavaScript Set, giving O(1) lookup. Text B is then walked line by line and each entry is checked against the set.

Order follows text B

Output preserves the order in which lines appear in text B. If line foo appears at position 3 in B and position 7 in A, the output places it at position 3.

Exact, case-sensitive match

Matching is byte-for-byte. Hello does not match hello, and foo does not match foo  with a trailing space. Use trim whitespace first if margin whitespace is causing misses.

Duplicates in B survive

A line that appears twice in B and once in A appears twice in the output. To collapse duplicates, run the result through remove duplicate lines.

Three-hyphen separator

The split between A and B is a line containing exactly ---. The separator line itself is not part of either set.

Worked example

Both banana and cherry appear in A and B, so they survive. apple is in A only and date is in B only. For those see find unique lines.

Input
apple
banana
cherry
---
banana
cherry
date
Output
banana
cherry

Settings reference

Behaviour Effect on output
Separator A line containing exactly --- splits text A from text B.
Match rule Exact string equality, case and whitespace sensitive.
Order Follows text B.
Duplicates in B Preserved. A repeated line in B that also exists in A appears once per occurrence.
Empty lines Counted as a line. If both sides contain empty lines, they appear in the output.
Trailing whitespace Significant. Strip first with trim whitespace if needed.
Missing separator Output prompts for two halves split by ---.

FAQ

Are matches case sensitive?
Yes. Apple in A will not match apple in B. Lowercase both sides first with lowercase if you want case-folded matching.
Why does a line that looks identical fail to match?
Almost always trailing whitespace. Run both sides through trim whitespace first to strip leading and trailing spaces from each line.
Is the order from text A or text B?
Text B. The tool walks B and keeps lines that exist in A's set, so the result follows B's order.
Will duplicate lines appear more than once?
Yes, if they repeat in text B. Pipe the result through remove duplicate lines to collapse them.
How is this different from word set intersection?
Word set intersection works on individual words, lowercased and deduplicated. Find common lines works on whole lines, exact and ordered.