Remove Duplicate Lines - Keep First or Last, See What Was Removed

Paste a list and the repeats disappear as you type, with a clear count such as '3 duplicate lines removed'.

About this tool

Keep the first or the last copy, ignore capital letters or stray spaces, leave blank lines alone, or switch the view to show only the lines that repeat or only the lines that never do. The order of what is left never changes, and nothing is uploaded.

How it works

Every line gets a comparison key: the line itself, trimmed if you ask, and lower-cased if you ask. The tool counts the keys in one pass, then reads the lines again and keeps the copy you chose. There is no sorting, so the original order is kept, and the work grows in step with the size of the text, so 200,000 lines take a fraction of a second. The Unix uniq command only finds repeats that sit next to each other (the GNU manual says repeated lines are detected only if they are adjacent). This tool compares every line with every other line, wherever they are, so the text does not need sorting first.

There are three views. 'Remove duplicates' keeps one copy of every line. 'Only the duplicated lines' shows each line that appears more than once, one time each, like uniq -d but across the whole text. 'Only lines that appear once' shows the lines that never repeat, like uniq -u. 'Which copy stays' decides whether the first or the last copy of a repeated line is kept. With the last copy, the lines are in the order of their last appearance.

'Ignore upper and lower case' compares lower-cased lines, so Apple and apple match, and the line you see is still the one you typed. It uses simple lower-casing, so ß and SS stay different. 'Trim spaces' removes spaces, tabs, non-breaking spaces and similar characters at both ends of every line before comparing, and the lines in the result are trimmed too. Blank lines can be left alone (the default, which keeps the gaps between paragraphs), treated like any other line (identical blank lines are reduced to one), or removed. A line that holds only spaces counts as blank.

The headline counts extra copies: a line that appears three times counts as two removed. Under the result, 'Which lines were duplicates' lists each repeated line with how many times it appeared and on which lines, so you can see what was dropped and check it. If two lines look the same but are not matched, the cause is usually a trailing space, a tab or a non-breaking space (turn on trimming), a difference in capitals (turn on ignore case), or an accented letter written as a letter plus a combining accent, which is a different sequence of characters from the single accented letter.

Worked examples

A list of emails

[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] has seven lines. ann appears three times and bob twice, so 3 duplicate lines are removed and ann, bob, cara and dev are left.

Keep the last copy

The same list with 'The last one' leaves cara, bob, ann, dev, because the last ann is on line 6, the last bob on line 5 and cara on line 4, so they appear in that order.

Only the repeats, or only the singles

'Only the duplicated lines' on the email list shows ann and bob. 'Only lines that appear once' shows cara and dev.

Capitals and spaces

Apple, apple, ' apple ', Banana, banana, Cherry, Apple with both 'Ignore upper and lower case' and 'Trim spaces' on gives Apple, Banana, Cherry and reports 4 duplicate lines removed. With both off, only the second 'Apple' counts as a duplicate, so 1 line is removed.

The three views for the lines a, b, a, c, c, c, d

ViewResultLike
Remove duplicatesa, b, c, dsort -u, but the original order is kept
Only the duplicated linesa, cuniq -d, but repeats need not be next to each other
Only lines that appear onceb, duniq -u, but repeats need not be next to each other

Frequently asked questions

How do I remove duplicate lines?

Paste the lines into the box. Repeats are removed at once and the headline says how many. Copy the result or download it as a text file. The first copy of each line stays unless you choose 'The last one'.

Does it keep the original order?

Yes. The lines that stay are in the order they had in your text, and nothing is sorted. If you want a sorted list as well, run it through Sort lines afterwards.

Do I need to sort the list first?

No. Unlike the Unix uniq command, which only sees repeats that are next to each other, this tool compares every line with every other line, so sorted or not makes no difference.

How do I see which lines were duplicated?

Open 'Which lines were duplicates' under the result. It lists each repeated line, how many times it appeared and the line numbers. Choose 'Only the duplicated lines' to get just those lines as text.

Why are two identical-looking lines not removed?

They differ by something you cannot see: a trailing space, a tab, a non-breaking space, a capital letter, or a different Unicode form of an accented letter. Turn on 'Trim spaces' and 'Ignore upper and lower case' first. If they are still not matched, the difference is in the characters themselves.

Is it case sensitive?

Yes by default, so Apple and apple are different lines. Tick 'Ignore upper and lower case' to treat them as the same. The copy you keep is shown as it was typed.

What happens to blank lines?

By default they are left exactly where they are, so paragraph gaps survive. You can treat them like any other line, which keeps one copy of each different blank line (with trimming on, that is a single blank line), or remove them all. A line with only spaces counts as blank.

How big a list can it handle?

Up to 5 million characters at once, about 5 MB of text. In testing, 200,000 lines with many repeats took well under a second. A longer text is refused with a message and nothing is changed.

Is my list uploaded anywhere?

No. The work is done in your browser and nothing you paste leaves the page. If you open a text file, it is read on your device and not sent anywhere.

Updated Oct 13, 2026