Remove Duplicate Lines

Remove duplicate lines from a list while keeping the first copy of each in its original position. The tool also shows how many lines went in and how many came out.

Updated

Text Tools● Free No upload Instant

Loading Remove Duplicate Lines…

Your browser is preparing the tool. It runs 100% locally.

Quick answer

Paste a list and the tool removes duplicate lines. It keeps the first occurrence of each and leaves everything in its original order. Lines are compared on their trimmed text, so two lines that differ only in surrounding spaces count as the same, and the comparison is case-sensitive. You also see how many lines went in and came out. The list never leaves your browser.

What the Remove Duplicate Lines does

Give the tool a block of lines and it returns only the unique ones. A line is kept the first time it appears, later identical lines are dropped, and the kept lines stay in the order you had them.

It cleans up a list of email addresses, URLs, names or log lines where the same entry has crept in more than once. Your data is not sorted or rearranged.

How it works

The tool reads your text line by line and remembers each line it keeps. When it meets a line it has already kept, it skips it. Lines are compared on their trimmed content, so leading and trailing spaces don't prevent a match.

Because it works through the lines in order and keeps the first of each, your original ordering survives. The line counts before and after tell you how many duplicates were removed.

Processing pipeline

  1. Read line by line. Split the text into lines and process them in order.
  2. Compare trimmed content. Match each line by its content with surrounding spaces ignored.
  3. Keep the first, drop repeats. Keep a line the first time it appears and skip any later identical lines.
  4. Show the counts. Report how many lines went in and how many remain.

How it de-duplicates

for each line, compare its trimmed text to the lines already kept first time seen → keep it seen before → drop it (order of the kept lines is preserved)
Worked example
apple / banana / apple / cherry → apple / banana / cherry (4 lines in, 3 out)

The first occurrence is kept and the order is preserved. Matching ignores surrounding spaces but is case-sensitive, so Apple and apple count as different lines.

Standards and references

  • First-occurrence de-duplication: A line is kept the first time it appears and later repeats are removed, so the earliest copy of a duplicated line is the one that survives.
  • Order preserved: The lines keep their original sequence. Nothing is sorted, so the cleaned list reads in the order you pasted it.
  • Trimmed, case-sensitive matching: Two lines match if their content is identical after surrounding spaces are trimmed. Capitalisation matters, so the same word in different case counts as a different line.

Accuracy and limits

For a plain list the result is exact. Each unique line appears once, in order, and every later duplicate is gone. The two line counts show how many repeats were removed.

Matching is case-sensitive. Apple and apple count as two different lines and both are kept. Convert the text to lower case first if you want case ignored.

Lines are compared on their trimmed content, so two lines that differ only in leading or trailing spaces count as duplicates. The output keeps the spacing of the first one.

Only whole-line duplicates are removed. Repeated words inside a line, near-duplicates and lines that differ only by punctuation are all kept as separate lines and need a different cleanup step.

Real-world uses

Cleaning a list

Remove repeated emails, URLs or names from a list.

De-duplicating log lines

Collapse repeated log entries to unique ones.

Tidying pasted data

Drop duplicate rows pasted from several sources.

Preparing import data

Make sure a list of values has no repeats before you import it.

When it fits, and when it doesn't

Good for

  • Removing repeated lines from a list
  • Keeping the first of each, in order
  • De-duplicating emails, URLs or names
  • A quick clean without sorting

Not the best choice for

  • Case-insensitive de-duplication (lower-case first)
  • Finding duplicate words within a line
  • Near-duplicate or fuzzy matching
  • Sorting the list at the same time

To ignore case, convert the text to lower case first and then remove duplicates. To sort as well, run the result through a line sorter. Near-duplicates need a fuzzy-matching tool, because this one removes exact whole-line repeats only.

Frequently asked questions

Which duplicate does it keep?
The first occurrence. A line is kept the first time it appears and any later identical lines are removed.
Does it sort the lines?
No. Your original order stays and only the repeats are dropped. If you want the list sorted as well, run the result through a line sorter afterwards.
Is the matching case-sensitive?
Yes. Apple and apple count as different lines, so both stay. To ignore case, convert the text to lower case first and then remove duplicates.
Do leading or trailing spaces affect matching?
No. Lines are compared on their trimmed content, so two lines that differ only in surrounding spaces count as the same. The output keeps the first line's original spacing.
Does it remove duplicate words within a line?
No. It removes repeated lines. Duplicate words inside one line stay, because that line as a whole is still unique.
What do the in and out counts show?
The first number is how many lines you pasted and the second is how many remain. The difference is the number of duplicates removed.
Are blank lines de-duplicated too?
Yes. A blank line trims to nothing, so several blank lines count as duplicates and only the first stays. Keep that in mind if blank lines mean something in your data.
Can it handle a very long list?
Yes. It remembers each unique line as it goes, so even a list of thousands of lines is cleaned quickly.
Will it change the lines themselves?
No. It only removes duplicate lines. Every line it keeps has its original text and spacing.
How is this different from removing all but unique lines?
Some tools remove every line that has a duplicate and leave only lines that appeared exactly once. This tool keeps one copy of each line, which is what most people mean by de-duplication.
Is my data uploaded?
No. Your browser removes the duplicates and sends nothing to a server, so the list stays on your device.
Can I de-duplicate comma-separated values?
The tool works on lines, so put each value on its own line first. Split comma-separated values onto separate lines, remove the duplicates, then join them again if you need to.

References

Lines are matched on their trimmed text and the match is case-sensitive. The first copy of each line stays where it was, and later repeats are dropped.

PopularHot

Word Counter

Count words, characters, sentences and paragraphs as you type, with reading and speaking time alongside.

TextOpen Tool

Remove Extra Spaces

Tidy messy spacing by collapsing repeated spaces and stacked blank lines. Single line breaks and paragraph gaps stay where they are.

TextOpen Tool

Remove Line Breaks

Remove line breaks and join text into one flowing line.

TextOpen Tool
Popular

Case Converter

Switch text between UPPERCASE, lowercase, Title Case, Sentence case, and aLtErNaTiNg with one click per case.

TextOpen Tool
Trending

Lorem Ipsum Generator

Generate placeholder Lorem Ipsum paragraphs, starting with the classic opening line or fully random.

TextOpen Tool
Trending

Text Diff Checker

Paste two versions of a text and see what changed line by line, with additions in green and removals in red.

TextOpen Tool

Back to the Remove Duplicate Lines

Your file is processed on this device and never uploaded, and there's no account to create.