Duplicate Line Remover

Keep each line once.

About Duplicate Line Remover

A duplicate line remover keeps the first occurrence of every line and drops the repeats, with options to ignore case or spaces and keep blank lines.

How to use

  1. Paste the lines. The unique lines appear on the right as you type.
  2. Adjust the options: "Ignore case" and "Keep blank lines" are off by default, "Ignore leading and trailing spaces" is on.
  3. Read the counts of lines in, lines out and removed, then Copy or Download unique-lines.txt.

Options

Option Default Effect
Ignore case off "Apple" and "apple" count as the same line
Ignore leading and trailing spaces on " apple" and "apple" count as the same line
Keep blank lines off Blank lines are removed; when on, the first blank line is kept and the rest are removed as duplicates
  • Order is preserved: the first occurrence stays where it was and later copies are removed.
  • The kept line is written out exactly as it appeared, even when "Ignore case" or the trim option decided it was a duplicate.
  • Lines are split on \n; a Windows \r\n file is handled because the trim option removes the trailing \r before comparing.
  • Does not sort the output, count occurrences or remove duplicates within a line.

Example

apple
banana
apple
cherry
→
apple
banana
cherry
Lines in 4 · Lines out 3 · Removed 1

Privacy

Deduplication runs in the browser. No request is made, and nothing is stored.

Frequently asked questions

How do I remove duplicate lines but keep the original order?
Keep a set of lines already seen and output each line only the first time it appears. This tool does that, so the result is in the original order; the Unix sort -u command, by contrast, sorts the lines first.
What is the difference between uniq and sort -u?
uniq only removes adjacent duplicates, so it is normally run after sort. sort -u sorts and deduplicates in one step. Neither preserves the original order; a set-based approach like this tool does.
Why are two lines that look identical not treated as duplicates?
They probably differ in invisible characters: trailing spaces, tabs, a non-breaking space, or letter case. Turn on "Ignore leading and trailing spaces" and "Ignore case", or check the lines in a hex viewer.