Duplicate Line Remover
A duplicate line remover deletes repeated lines from a list and keeps one copy of each. Paste your lines, choose whether to ignore case and surrounding spaces, and copy the result. The first copy stays in its original place, so the order of your list does not change. You can also keep only unique lines.
How to use the duplicate line remover
- Paste your list into the top box, one item on each line. The result appears underneath as you type or paste.
- Choose what to keep. One copy of every line is the usual choice. The other two choices keep only lines that appear once, or only lines that appear more than once.
- Decide how lines are compared. Tick Ignore upper and lower case if Apple and apple should count as the same line. Leave spaces ignored at the start and end of lines unless they matter.
- Read the note under the result, which says how many lines went in and out, then press Copy result or Download .txt.
How duplicate lines are found
The tool reads your text from top to bottom and decides, line by line, whether it has seen that line before. It follows these steps.
- Split into lines. Your text is cut at every line break, whether it comes from Windows, Mac or Linux.
- Build a comparison form of each line. The text is put in a standard Unicode form (NFC), so an accented letter typed as one character and the same letter typed as a base letter plus an accent are treated as equal. Spaces and tabs at the start and end are removed unless you switch that off, and capital letters are made lower case if you tick Ignore upper and lower case. This form is used only for comparing. It never changes what you see in the result.
- Keep or drop. The first time a form appears, the line is kept exactly as you typed it. Later lines with the same form are dropped. Your list is not sorted, so the order of what remains is the order you gave.
- Blank lines. By default, empty lines are left alone, so the gaps between groups of lines survive. Untick Keep blank lines and they are treated like any other line, which leaves one empty line at most.
- Other modes. Only lines that appear once keeps the lines that have no copy anywhere in the text. Only lines that appear more than once keeps one copy of each repeated line, which shows you what was duplicated.
Lines that differ in any other way count as different lines. A line with an extra full stop, or a line that contains a no-break space where the other has a normal space, is not a duplicate. The tool compares the whole list in one pass and does not need the lines to be sorted or next to each other, which is where the Unix uniq command differs: it only compares neighbouring lines.
Worked example
This list has nine lines. A middle dot (·) marks a space, and ↵ marks the end of a line in the table below:
apple Banana apple cherry ··banana·· Cherry cherry fig apple
With the default settings, the tool compares lines exactly, apart from spaces at the ends. “apple” appears three times and “cherry” twice, but “Banana” and “banana” differ by a capital letter, so both stay. 3 lines are removed and 6 remain. Ticking Ignore upper and lower case removes 5 lines in total and leaves 4. The three modes give these results with that box ticked:
| Setting | Result | Lines |
|---|---|---|
| Exact match | apple↵Banana↵cherry↵··banana··↵Cherry↵fig | 6 |
| Ignore case, one copy of every line | apple↵Banana↵cherry↵fig | 4 |
| Ignore case, only lines that appear once | fig | 1 |
| Ignore case, only lines that appear more than once | apple↵Banana↵cherry | 3 |
The options at a glance
| Option | What it does | Typical use |
|---|---|---|
| One copy of every line | Keeps the first copy of each line and drops the rest | Cleaning a list of emails, names, URLs or keywords |
| Only lines that appear once | Drops every line that has a copy anywhere in the text | Finding the items that are in the list only once |
| Only lines that appear more than once | Keeps one copy of each repeated line | Seeing which items were duplicated |
| Ignore upper and lower case | Treats Apple and apple as the same line | Email addresses, tags and names typed in mixed case |
| Ignore spaces at the start and end | Compares lines without their outer spaces | Lists with stray indentation or trailing spaces |
| Keep blank lines | Leaves empty lines where they are | Lists divided into groups by blank lines |
Frequently asked questions
Does the tool keep the first or the last copy of a repeated line?
It keeps the first copy, in the place where it first appeared. Later copies are removed, so the order of your list does not change.
Does it sort my lines?
No. The lines that remain stay in the order you pasted them. The Unix uniq command is different: it only removes repeated lines that sit next to each other, so a list has to be sorted first.
Why are Apple and apple both still in my result?
The tool matches exactly by default, and the two lines differ by a capital letter. Tick Ignore upper and lower case to treat them as the same line.
Why do two lines that look identical both stay?
Something invisible differs between them. Common causes are a no-break space instead of an ordinary space, a space inside the line rather than at its ends, or a different punctuation mark. Run the text through the remove extra spaces tool first to standardize the spaces.
How many lines can it handle?
It checks each line once, so long lists are quick. In our tests a list of 100,000 lines took well under a second to process. The practical limit is how much text your browser can show in a box, and a phone copes with less than a computer.
Is my text uploaded or stored?
No. The lines are compared in your browser and your text never leaves your device.
Related tools
- Sort LinesAlphabetize a list A to Z or Z to A, or sort it by number, length or at random.
- Remove Empty LinesDelete blank lines, or keep just one between paragraphs.
- Remove Extra SpacesCollapse double spaces, trim lines and fix tabs and no-break spaces.
- Remove Line BreaksJoin broken lines into one paragraph, with options for paragraphs and hyphens.
- Diff CheckerCompare two texts and see added, removed and changed lines and words.
- Case ConverterSwitch text between upper, lower, title, sentence, camelCase, snake_case and more.
Sources and references
- The Open Group: uniq utility (POSIX) — defines uniq as comparing adjacent lines only
- Unicode Standard Annex #15: Unicode Normalization Forms — why identical-looking text can be encoded in different ways