Duplicate Line Remover

Paste a list, one item per line, to delete every repeated line and keep the first copy of each in the order you pasted them.

Paste a column from a spreadsheet, a list of emails or any text. The result changes as you type.
Show
More Options

Results

3 repeats removed

Lines Without Repeats

Most Repeated Lines

  1. ana@example.com3
  2. chloe@example.com2

9 lines in, 6 lines out. 2 lines were repeated, with 3 extra copies.

How to Remove Duplicate Lines

  1. Paste your list into Your Lines, one item per line.
  2. Read the result on the right. Each line appears once, at the place of its first copy, and the lines are in the order you pasted them in.
  3. Turn on Ignore case to count Ben and ben as the same line. Ignore spaces at line starts and ends is on by default, so a value with a stray space after it is still the same line.
  4. Under Show, pick Repeated Only to see one copy of each line that appears more than once, or Once Only for the lines that appear a single time.
  5. Check Most Repeated Lines for each repeated line and how many times it appears, then select Copy Lines to copy the result.

Example of an Email List With Repeats

The starting list has 9 email addresses. Three are repeats, and one of them, the second chloe, has a space at the end. With the default settings 6 lines are left:

ana@example.com ben@example.com chloe@example.com Ben@example.com dev@example.com emma@example.com

The note under the result is 9 lines in, 6 lines out. 2 lines were repeated, with 3 extra copies. Most Repeated Lines has ana@example.com 3 times and chloe@example.com 2 times. Ben@example.com is still next to ben@example.com, because with the capital B it is a different line until you turn on Ignore case; then 5 lines are left. Under the email standard RFC 5321, mail servers must treat the part before the @ as case sensitive, though most providers do not, so check before you merge addresses that differ only in capitals.

The Same Email List With Each Setting

These are the results for the same 9 addresses:

SettingResultLines Out
Default settingsana@example.com
ben@example.com
chloe@example.com
Ben@example.com
dev@example.com
emma@example.com
6
Ignore case onana@example.com
ben@example.com
chloe@example.com
dev@example.com
emma@example.com
5
Keep the last copy instead of the firstben@example.com
Ben@example.com
dev@example.com
ana@example.com
chloe@example.com
emma@example.com
6
Ignore spaces at line starts and ends offana@example.com
ben@example.com
chloe@example.com
Ben@example.com
dev@example.com
chloe@example.com
emma@example.com
7
Repeated Onlyana@example.com
chloe@example.com
2
Once Onlyben@example.com
Ben@example.com
dev@example.com
emma@example.com
4

With Keep the last copy instead of the first, each line appears at the place of its last copy, so ana is lower, at the place of its third copy. With Ignore spaces off, the chloe address with a space at the end counts as a different line and is kept.

What Counts as a Duplicate Line

Two lines are duplicates when their text is the same, letter for letter. Capital and small letters differ unless Ignore case is on, and spaces inside a line count, so a b and a b with two spaces are different lines. Spaces, tabs and no-break spaces at the start and end of a line are ignored while the switch is on, and the copy that is kept still has its spaces as pasted.

An accented letter can be typed as one character or as a letter followed by a combining accent. The two look the same and are matched as the same, so Café typed both ways is one line in the result. Blank lines are never counted as repeats: they are left where they are, or all removed with Remove blank lines. In the lines red, a blank line, blue, a blank line, red and a blank line, only the second red is removed; with Remove blank lines on, the result is red, blue.

Remove Duplicate Lines in Linux With Sort and Uniq

On Linux and macOS, with the uniq command a repeated line is removed only when the copies are next to each other, and for repeats anywhere in a file the GNU manual has sort -u. The output of sort -u is in sorted order, so the original order is lost. Paste the lines into Your Lines to keep them in their original order, then use the Alphabetize List tool if you want them sorted as well.

How Lines Are Compared and Counted

The text is read line by line. A line ends at a line feed, a carriage return, the two together (CR LF), the next line character (U+0085), the line separator (U+2028) or the paragraph separator (U+2029), and one line break at the very end of the text is ignored. For each line that is not blank, a comparison copy is made: spaces at both ends are removed if the switch is on, the text is put in Unicode NFC form, and with Ignore case it is written in small letters. Lines with the same comparison copy are duplicates.

Each comparison copy is counted, with the places of its first and last copies. With Without Repeats, the line is kept at the first or last place; with Repeated Only, it is kept only when the count is more than one; and with Once Only, lines with a count of one are kept. Most Repeated Lines has up to 50 lines, the most copies first, then in the order they first appear. The lines are compared in your browser and are not sent anywhere.

FAQs

Q1. How Do I Remove Duplicate Lines From a List?

To remove duplicate lines from a list, paste it into Your Lines, one item per line. The tool deletes every repeated line and keeps the first copy in its place, so the 9 sample addresses become 6. Select Copy Lines to copy the list without repeats.

Q2. Does Removing Duplicates Keep the Original Order?

Yes, the lines keep the order you pasted them in. Each line appears at the place of its first copy, or of its last copy with the switch under More Options, and nothing is sorted, which is the main difference from sort -u on the command line.

Q3. Is the Duplicate Line Remover Case Sensitive?

The duplicate line remover is case sensitive by default, so Apple and apple are two different lines. Turn on Ignore case to treat them as one, and the copy that appears first is the one that stays, with its capitals as typed.

Q4. How Do I Find Which Lines Are Duplicated?

To find which lines are duplicated, look at Most Repeated Lines, which lists each repeated line with the number of times it appears, or pick Repeated Only under Show. For the sample list both give ana@example.com, which appears 3 times, and chloe@example.com, which appears 2 times.

Q5. How Do I Keep Only the Lines That Appear Once?

To keep only the lines that appear once, pick Once Only under Show. Every line that has a copy anywhere in the list is left out, including its first copy, so the result has only the values that were never repeated, such as the lines that are in just one of two lists pasted together.

Sources

RFC 5321, Simple Mail Transfer Protocol (IETF, October 2008), section 2.4, for case in the part of an address before the @. GNU Coreutils manual, uniq invocation, for uniq finding only adjacent repeats and the sort -u suggestion. Unicode Standard Annex #15, Unicode Normalization Forms, for NFC. Unicode Standard Annex #14, Unicode Line Breaking Algorithm, for the characters that end a line.