Remove duplicate lines — keep the first occurrence

Remove repeated text lines while keeping the first occurrence and original order. Choose case-sensitive matching, then copy or download the cleaned list.

Output
Enter text to see output.

What to know

This operation walks down the list once and keeps a line only the first time it appears, so the original order survives. It does not sort anything, which makes it the right first step for e-mail lists, URL lists and keyword exports where the order carries meaning.

Two lines count as the same when they match after trimming spaces at both ends and, by default, ignoring upper and lower case. The checkbox labelled Treat uppercase and lowercase as different turns the case folding off, which suits SKUs, hashes and codes where AB12 and ab12 are different items.

The surviving line is the first original, untouched, with its own spacing. Input Apple, then apple with a trailing space, then Banana, a blank line, Cherry, another blank line and banana gives Apple, Banana, a blank line and Cherry: the blank line is treated like any other value, so only the first one stays.

Lines that differ inside, such as a b with two spaces against a b with one, or hello and hello!, remain separate. Run trim whitespace first if inner spacing varies, and use remove empty lines afterwards if you want the single surviving blank line gone too.

Worked example

The default comparison ignores letter case and leading or trailing spaces. It preserves the text of the first matching line. Enable the case option when identifiers such as Blue and blue must stay separate.

Input

Blue
blue
Green
Blue

Output

Blue
Green

Repeated blank lines are also duplicates: one can remain. Use Remove empty lines afterward if the list must contain no blank rows. Deduplication does not sort the list.

Choose a specific task 10
Related tools 4
How to use Remove duplicate lines — keep the first occurrence
  1. Paste a list of five or more lines, such as a column of e-mail addresses copied from a spreadsheet, into the Text input box.
  2. Leave the case checkbox off for addresses, or tick it for part numbers where AB12 and ab12 must both stay.
  3. Compare the Output panel against the input and note how many lines vanished, for example 1,200 down to 870.
  4. Copy the result with the copy icon and paste it back into your sheet, replacing the original column.

Quick answers

Which copy of a duplicate line is kept?

The first one, exactly as you typed it, including any extra spaces. Later copies, even with different capitalization or edge spaces, are dropped.

Are repeated blank lines removed too?

They are reduced to a single blank line, because an empty line is compared like any other. Use remove empty lines to delete them all.

Does it sort the output?

No, the surviving lines stay in their original order, which is the main difference from running a sort and then removing neighbours.

Why was Apple kept but apple removed even though they look different?

By default capitalization and spaces at the line edges are ignored when comparing, so both are the same entry. Tick the case checkbox if they must stay distinct.