Menu

Remove Duplicate Lines

Paste a list with one item per line and every repeated line is removed at once, keeping the first copy of each line in its original order and showing how many duplicates went.

0 words 0 characters 0 lines

Continue with this text: Sort linesRemove empty linesCount lines

Your text stays in your browser: nothing is uploaded or stored on a server.

How to remove duplicate lines

  1. Paste your list into Your list (one item per line), or use Open file for a .txt or .csv file. Example loads a short sample.
  2. Check the matching options. By default, case and extra spaces are ignored, so Apple and *apple * count as the same line.
  3. Choose which copy to keep under Keep: First occurrence (default) or Last occurrence.
  4. Read the result. The note shows how many duplicate lines were removed, and Repeated lines lists each line that had copies.
  5. Click Copy or Download .txt, or continue with Sort lines, Remove empty lines or Count lines.

The result updates as you type or change an option, and Use as input moves the result into the input box if you want to run another tool on it.

The options and what they change

Option Default What it does
Case-sensitive (Apple ≠ apple) Off When off, lines that differ only in capital letters count as duplicates. When on, Hello, hello and HELLO are three different lines.
Ignore extra spaces (start, end, doubled, zero-width) On Spaces and tabs at the ends of a line are ignored, runs of spaces inside the line count as one space, and zero-width spaces (U+200B, U+2060, U+FEFF) are ignored. When off, banana and banana␣␣ are different lines.
Keep First occurrence First occurrence keeps the first copy where it is. Last occurrence keeps the last copy of each line, in the position of that copy.
Remove empty lines too Off When off, blank lines stay where they are. When on, every blank line is deleted, including lines that contain only spaces, and the note adds how many empty lines were removed. A line break at the very end of the text only ends the last line: it is kept and not counted as an empty line.

The options only decide which lines count as duplicates. The line that stays is copied exactly as you typed it: if the first copy is banana␣␣ with two trailing spaces, those spaces stay in the result. To clean the spacing itself, run the result through remove extra spaces.

How duplicates are compared

The tool reads your text line by line. A line ends at a line break of any kind (Windows CRLF, Unix LF or old Mac CR), and the result always uses plain LF line breaks. For each line it builds a comparison key from the options above and keeps a line only if that key has not been seen before. This is why the order of your list does not matter: two copies are found even if they are thousands of lines apart.

The rules that decide the cases people ask about, with default settings:

Lines Treated as Why
Apple and apple Duplicates Case is ignored by default.
New York and New York Duplicates Extra spaces inside a line count as one when the spacing option is on.
straße and Straße Duplicates Lowercasing works for accented and non-Latin letters too.
café and cafe Different Accents are compared, not removed. Use remove accents first if they should match.
https://example.com/a and https://example.com/a/ Different Only case and spacing are relaxed; every other character must match.
é typed as one character and é typed as e + combining accent Duplicates Lines are compared after Unicode normalization (NFC); the kept line stays as typed.
Two blank lines Not compared Blank lines are left where they are and never count as duplicates.

Two cases can surprise you:

  • Blank lines. With Remove empty lines too off, blank lines are never treated as duplicates: every one stays in its place, and the note counts only duplicate lines with text. a, blank, b, blank, a becomes a, blank, b, blank, with “1 duplicate line removed”. When a removed line sat between two blank lines, those blank lines end up next to each other; remove empty lines can collapse them to one.
  • Characters that look the same. Accented letters are normalized before comparing, and with the spacing option on, a zero-width space inside a line is ignored. Letters from different alphabets are still different characters, though: a Cyrillic а does not match a Latin a. Remove invisible characters helps when a line still refuses to match.

Worked examples

The example list, with default settings:

apple
banana
Apple
cherry
banana  
banana
date
Setting Result Removed
Defaults (keep first) apple, banana, cherry, date 3
Keep: Last occurrence Apple, cherry, banana, date 3
Case-sensitive on apple, banana, Apple, cherry, date 2
Ignore spaces off apple, banana, cherry, banana␣␣, date 2

Repeated lines shows banana 3 times and apple 2 times.

Keeping the last copy is useful when a list is a log and the latest entry matters. Here each line is a status update, in order:

Before Keep first Keep last
status: open
status: closed
status: open
status: pending
status: closed
status: open
status: closed
status: pending
status: open
status: pending
status: closed

Both keep three lines; Keep last orders them by when each value was last seen.

A keyword list exported from two tools, with default settings:

running shoes
Running Shoes
trail running shoes
running  shoes
waterproof hiking boots
trail running shoes 

becomes running shoes, trail running shoes, waterproof hiking boots, with 3 lines removed.

When people need it

  • Mailing lists. Contacts exported from a CRM, a webinar tool and a spreadsheet overlap. Paste the email column and keep the defaults: different capitalization and trailing spaces from the export are ignored.
  • Keyword and hashtag lists. Merged keyword research usually repeats the same phrase in different case. Dedupe it, then check keyword density in your draft.
  • URLs and file names. Lists of links from a crawl or a folder listing. Turn on Case-sensitive if the server treats /Page and /page as different addresses.
  • Code and data. IDs for an SQL IN list, values for a dropdown or entries in a config file. After deduping, the comma separator turns the column into 'a', 'b', 'c'.
  • Names and guest lists. Sign-ups collected from several forms. Exact matching cannot catch Jon Smith and John Smith, so read the result once.

How this compares with Excel and the command line

In Excel, Data > Remove Duplicates deletes repeated rows from the selected range, and you choose which columns to compare. Microsoft notes that the duplicates are permanently deleted, so it suggests copying the data first. Here the original stays in the input box.

On Linux and macOS, uniq removes a repeated line only when the copies are next to each other, according to the GNU Coreutils manual, so it is normally used after sort or replaced by sort -u. Both sort the output. This tool finds copies anywhere in the list and keeps your original order, which matters for ranked lists, logs and anything written in a meaningful sequence. If you do want an alphabetical result, the sort lines tool has its own Remove duplicates option. The guide to removing duplicate lines covers more programs.

Questions

Does removing duplicates change the order of my list?

No. The lines that stay keep their original order. With Keep: Last occurrence, each line moves to the position of its last copy instead. To sort the result, open it in the sort lines tool.

Is the comparison case-sensitive?

Not by default, so Apple, apple and APPLE count as one line and the first spelling is kept. Tick Case-sensitive (Apple ≠ apple) to treat them as three different lines.

How do I remove duplicate email addresses from a list?

Paste one address per line and keep the defaults. [email protected] and [email protected] count as the same address, and trailing spaces from a spreadsheet export are ignored. If the addresses are mixed into other text, use the email extractor first.

How can I see which lines were duplicates?

Open Repeated lines under the options. It lists every line that appears more than once and how many times, most frequent first, up to 50 lines. The note above the result shows how many duplicate lines were removed (and, with Remove empty lines too, how many empty lines).

Can I keep only the lines that never repeat?

Not with this tool. It always keeps one copy of each repeated line. The Repeated lines table shows which lines had copies, so you can delete those by hand or with remove lines containing.

Is there a limit on how many lines I can paste?

There is no fixed limit. The comparison uses a lookup set, so time grows in step with the number of lines: in a test, a 200,000-line list was deduplicated in well under a second.

Is my list uploaded anywhere?

No. The comparison runs in your browser and the list is not sent to a server, which matters for customer lists and email addresses.