Remove Duplicate Lines From a List
Paste a list with repeats in it and get back one copy of each line, plus a count of what was removed and a report of which lines appeared more than once.
This tool runs in your browser. Nothing you type is uploaded or saved, and there is nothing to install or sign up for.
When you need to remove duplicate lines
Lists pick up repeats whenever they are built from more than one place: two sign-up sheets merged into one, email addresses copied from several messages, vocabulary collected over a few lessons, or survey answers pasted from a spreadsheet. Hunting for the repeats by eye is slow, and in a list of a few hundred lines you will almost certainly miss some.
This tool reads your list line by line, keeps one copy of each different line and throws the extra copies away. It also tells you how many were removed and names the lines that were repeated, so you can see what happened instead of trusting it blindly.
How to clean a list
- Paste your list into the box, with one item on each line.
- Check the four tick boxes. Trimming spaces and removing empty lines start switched on; exact case matching and sorting start off.
- Under When a line repeats, keep, choose The first copy or The last copy.
- Read the four tiles, then press Copy unique lines to take the cleaned list.
Everything recalculates as you type or tick. Clear empties the box and Reset restores the sample fruit list and the starting options.
The sample list, line by line
The tool opens with eight lines. The sixth is blank and the seventh has a stray space after the word.
| Line | Text | What happens |
|---|---|---|
| 1 | apple | Kept (first time seen) |
| 2 | Banana | Kept |
| 3 | apple | Removed, same as line 1 |
| 4 | cherry | Kept |
| 5 | banana | Removed, matches line 2 when case is ignored |
| 6 | (blank) | Removed as an empty line |
| 7 | Apple + space | Removed, matches line 1 after trimming |
| 8 | cherry | Removed, same as line 4 |
The result is three lines: apple, Banana, cherry. The tiles read 8 lines in, 3 unique lines out, 4 duplicates removed and 1 empty line removed, and 3 + 4 + 1 adds back up to 8. The report underneath lists apple 3 times, Banana 2 times and cherry 2 times.
Now tap The last copy. The same three items survive, but the tool keeps the final appearance of each, so the result becomes banana, Apple, cherry, in the order those last copies appear. Tick Match upper and lower case exactly with the first copy kept and five lines survive instead: apple, Banana, cherry, banana, Apple.
How lines are compared
Two lines count as duplicates when their comparison keys are identical. The key is built from the line in up to two steps:
- With Trim spaces on, spaces and tabs at the two ends of the line are cut off. The cleaned list also shows the trimmed version.
- With Match upper and lower case exactly off, the line is turned to lowercase for the comparison only. The copy you get back keeps its original capitals.
The tool then walks through the list once, remembering every key it has met. A line whose key is new is kept; a line whose key was already met is counted as a duplicate. For the last-copy setting the walk runs from the bottom of the list upward and the result is turned back the right way round.
Empty lines are counted separately. With Remove empty lines on, every blank or space-only line is dropped. With it off, blank lines are treated like any other text, which means one blank line is kept and the rest are counted as duplicates.
Sort the result A to Z is applied last, ignoring capitals. Leave it off when the original order matters, such as steps in a process or a ranking.
What it will not catch
- Near matches. Lines must be the same character for character after trimming. Jon Smith and John Smith, or color and colour, are different lines.
- Spaces in the middle. Trimming only touches the ends. Two spaces between words instead of one makes a different line.
- Punctuation. A trailing comma or period is part of the line, so apple, does not match apple.
- Repeats inside a line. The tool compares whole lines. It does not remove a repeated word within a sentence.
- Comma-separated lists. Put each item on a separate line first. A spreadsheet column pasted in already arrives that way.
Before deleting anything important, glance at the repeated-lines report. If a name appears there that should not, the list may hold two different people who share a name.
Handy uses for teachers and students
Merging class sign-ups is the classic case: paste the lists from two forms one under the other, remove the duplicates, and you have a single register. From there the alphabetical order sorter gives finer control over ordering, and the random team generator can split the clean list into groups without anyone landing in two teams.
For vocabulary work, paste every word a class suggested during a brainstorm. The unique list is your word bank, and the report shows which words came up most often. If the entries have messy capitals, run the result through the case converter afterward.
Students building a reference list or a set of flashcard terms from several sets of notes can use the same trick, then load the cleaned terms into the flashcard maker.
Outside school it works for mailing lists, inventory codes, tags and keywords. Anything that fits one item per line can be cleaned this way.
Related helpers are grouped under tools for working with text, and the complete tools page lists every calculator and classroom helper available.
Frequently asked questions
How do I remove duplicate lines from a list?
Paste the list with one item per line. The tool keeps one copy of each line and removes the rest straight away. The eight-line sample is reduced to three lines: apple, Banana and cherry.
Does it keep the original order of my list?
Yes. Unless you tick the sort option, the lines that survive stay in the order they appeared. You can choose whether the first or the last copy of a repeated line is the one that stays.
Are Apple and apple treated as the same line?
By default yes, because capitals are ignored when comparing. Tick Match upper and lower case exactly to treat them as different lines.
What is the difference between keeping the first and the last copy?
It changes which spelling and position survive. In the sample, keeping the first copy gives apple, Banana, cherry, while keeping the last copy gives banana, Apple, cherry.
Why were some lines that look the same not removed?
They probably differ in a way that is hard to see, such as a double space in the middle, a trailing comma or a different spelling. Only lines that match exactly after trimming count as duplicates.
Is there a limit on how many lines I can paste?
There is no fixed limit. The work is done in your browser, so lists of several thousand lines are handled quickly on an ordinary laptop or phone.
