OnlineTextLab
Esc

Remove Duplicate Lines

Deduplicates a list without reordering it, catches near-duplicates that differ only by case or spaces, and shows you what repeated.

When a line repeats

Ctrl or Cmd + Enter copies the result.

Runs on your device. Your files and text are not uploaded.

About Remove Duplicate Lines

Lists pick up duplicates whenever two sources are combined: mailing lists, URL exports, product codes, keyword research. Paste the list and each repeated line disappears as you watch, with the order of everything else untouched. A count shows how many lines came in, how many stayed and how many went.

The usual problem with deduplicating is the copies you cannot see. [email protected] with a trailing space and [email protected] look like different lines to a computer. Spaces at the ends are ignored by default, and Ignore case takes care of capitals when you want that too.

You choose which copy survives: the first, the last, or none at all, which leaves only lines that appeared once. The Most repeated list shows which lines occurred most often, which often tells you something about the data itself.

How it works

Each line is turned into a comparison key: with spaces trimmed from both ends if that option is on, and lowercased if Ignore case is on. The tool records every key in one pass and then filters a second time, keeping the copy you asked for. The surviving line keeps its original spelling and spacing, as only the comparison is normalized. Because it uses a hash lookup, each line takes about the same time to check however long the list grows.

Blank lines are left alone by default, because removing them as duplicates would close up the gaps in a text with paragraphs. Turn off Leave blank lines alone and they are treated like any other line, so only the first blank line stays.

Unlike the Unix uniq command, which only catches repeats that are next to each other, this finds a repeat anywhere in the list, so you do not need to sort first.

How to use Remove Duplicate Lines

  1. Paste your list into the Lines with repeats box, or press Upload for a text or CSV file. Try an example shows a list of emails with hidden differences.
  2. Choose what happens under When a line repeats: Keep the first, Keep the last or Remove every copy.
  3. Set Ignore case and Ignore spaces at the ends to suit your data.
  4. Check the counts and the Most repeated list under the result.
  5. Press Copy, or Ctrl or Cmd + Enter, for the clean list. Download saves it as unique-lines.txt.

An email list with hidden duplicates, with Ignore case on

Input
[email protected]
[email protected]
[email protected]
 [email protected]
[email protected]
Output
[email protected]
[email protected]
[email protected]

Five lines in, three kept, two removed. With both options off, nothing would be removed here, because each of the five lines differs in some small way.

When it helps

  • Merging newsletter lists from two systems and removing people who are on both.
  • Cleaning a keyword list pulled from several research exports.
  • Reducing a log to its distinct messages, with Most repeated showing the noisiest ones.
  • Finding the entries that appear in only one of two lists: paste both together and choose Remove every copy.

Tips for a better result

  • Use Keep the last when your list runs oldest to newest and later entries are more up to date.
  • Leave Ignore case off for case-sensitive data, such as passwords, file paths on Linux or product codes where aB1 and AB1 differ.
  • Comparing whole lines means CSV rows only match if every column matches. To deduplicate on a single column, extract that column first.
  • If you want the result in order as well, run it through Sort Lines afterwards, or turn on Remove duplicates there.

Good to know

  • It compares whole lines, so it cannot find duplicate words inside a line, or similar lines that differ by a typo.
  • Accented and unaccented forms are different lines: café and cafe both stay, even with Ignore case on.
  • Files can be up to 20 MB. A paste of that size can take a moment to appear in the box, depending on your browser.

Questions people ask

Does removing duplicates change the order of my list?

No. Lines stay in their original order, apart from the ones removed. With Keep the last, each surviving line stays at the position of its final copy, so a line can sit lower than it first appeared.

Why are some duplicates not being removed?

The lines are not quite identical. Common causes are capital letters, a trailing space or tab, or a non-breaking space from a web page. Turn on Ignore case, and keep Ignore spaces at the ends on. If a pair still survives, they differ by a character you cannot see, or by an accent.

How do I keep only the lines that appear once?

Choose Remove every copy. A line that appears twice or more then disappears completely, and only lines that were already unique stay. This is handy for comparing two lists pasted together.

What to use next

Last reviewed . Read our editorial policy.