TheFileTools

How to remove duplicate lines from a list

Keep each email address, keyword or name once, including repeats that differ only in capitals or spaces.

Two mailing lists merged into one, keywords collected from several sources, a log with the same message again and again. The repeated lines have to go, and the rest should stay in its original order.

Steps

  1. Open Remove duplicate lines.
  2. Paste the list, one item per line.
  3. The result appears with each line kept once. The first copy stays where it was and later copies are removed.
  4. Press Copy.

Why some duplicates survive

Two lines only count as duplicates when they match character for character. Lists gathered from different places usually differ in small ways, and two boxes deal with that.

  • Trim spaces removes spaces at the start and end of each line. A copy with an invisible trailing space is the most common reason a duplicate is missed.
  • Ignore upper/lower case treats Anna@example.com and anna@example.com as the same line. The spelling that appears first is the one that is kept.

Differences inside a line, such as a double space or a different kind of dash, are not ignored. Clean up text can collapse repeated spaces before you remove duplicates.

Empty lines and order

Empty lines are lines too, so several of them shrink to one. Tick Remove empty lines to drop them all.

Order starts on Keep order. Change it to A → Z if you want the cleaned list sorted in the same step. This page is Sort lines with different starting settings, so every option there is available here.

Check the result

The tool does not report how many lines it removed. To find out, paste the list into Word counter before and after and compare the Lines figure.