Skip to content

Remove duplicate lines

Delete repeated lines from a list, keeping the original order.

Updated

Keep

How to remove duplicate lines

  1. Paste your list with one item per line, or open a .txt or .csv file.
  2. Choose whether to ignore capitals, trim spaces and drop empty lines.
  3. Pick which copy of each repeat to keep: the first or the last.
  4. Copy the result or download it as a text file. The summary shows how many lines were removed.

What each option does

InputSettingResult
apple, Apple, appleDefaultapple, Apple
apple, Apple, appleIgnore caseapple
apple, Apple, appleIgnore case, keep last copyapple (the third line)
“pear”, “ pear ”Trim spaces on (default)pear
“pear”, “ pear ”Trim spaces off“pear”, “ pear ”
a, (blank), b, (blank)Remove empty lines on (default)a, b

Keeping the first or the last copy

Keeping the first copy is what most people expect: the list reads the same, minus the repeats. Keeping the last copy matters when a list grows over time, such as a log, a changelog or an export where later rows replace earlier ones: each line stays where it last appeared.

Need the list in alphabetical or numeric order as well? Sort lines sorts and removes duplicates in one step.

Common uses

  • Cleaning a mailing list. Paste email addresses from several exports, turn on Ignore case, and get each address once in the order they came, ready to import.
  • Unique values from a spreadsheet column. Copy a column of product codes or city names and remove the repeats to see each value once; the summary says how many were removed.
  • Tidying log lines or keyword lists. Drop repeated lines from a log excerpt or a merged keyword list without changing the order, keeping the last occurrence when later lines matter more.

Questions

Does it change the order of my list?

No. Lines stay in the order you pasted them; only the repeats are taken out. To sort the list as well, use Sort lines, which can alphabetize and remove duplicates together.

Are “Apple” and “apple” duplicates?

Not by default: lines must match exactly. Turn on Ignore case to treat them as the same line; the copy that's kept keeps its own capitals.

What's the difference between keeping the first and the last copy?

Which repeat survives, and so where it sits. Keeping the first leaves each line where it first appeared. Keeping the last leaves it where it last appeared, useful when later entries in a log or export are the most recent.

Why are lines with extra spaces still there?

With Trim spaces off, “ben” and “ben ” are different lines. It's on by default, removing spaces and tabs at the start and end of each line before comparing.

All text tools →