Remove Duplicate Lines

Clean a list by deleting repeated lines.

How it is calculated

The tool splits your text into lines at each line break (Windows, Mac and Unix endings are all recognised), then walks through them from top to bottom. A line is kept only the first time it appears; every later identical line is dropped. The original order of the survivors is preserved, and the result reports how many lines were removed: removed = lines in − lines out. Comparison is exact and character-for-character, so case, leading or trailing spaces and punctuation all count. Empty lines are treated like any other line, which means only the first blank line stays. Nothing is sorted or trimmed.

Worked example

Paste six lines: apple, banana, apple, cherry, banana, apple. The first apple and the first banana are new, so they stay. The second apple is already seen and is removed. Cherry is new and stays. The second banana and third apple are removed. The output is apple, banana, cherry on three lines, and the tool reports 3 lines removed (6 in, 3 out).

Try this example →

Common mistakes

  • Expecting "Apple" and "apple" to count as duplicates. The match is case-sensitive, so lowercase the list first if you want them merged.
  • Trailing spaces. "apple" and "apple " look identical but are different lines and both survive.
  • Expecting the list to come back sorted. Order is kept as first seen; sort separately if you need alphabetical order.
  • Forgetting that blank lines are lines too. Several blank separators collapse into one, which can change the layout of a structured list.
  • Pasting comma-separated values on one line. The tool works per line, so each line would need to hold a single item.

About this calculator

This tool cleans a block of text by removing duplicate lines, comparing each line to the ones seen before it and keeping only the first occurrence, so the original order of the remaining lines is preserved rather than sorted or shuffled. It works purely on exact line matches, so two lines that differ by even a trailing space or a capital letter are treated as different.

It is used by developers cleaning up log files, CSV exports or lists of URLs and email addresses that have accumulated repeated entries, and by anyone merging two lists — contacts, tasks, keywords — who wants a single clean version without manually scanning for repeats. It's a routine step before importing a list into a spreadsheet or database where duplicate rows would cause errors or skew counts.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    Lines are compared exactly, so Apple and apple count as different, and so does a line with a trailing space. If a list still shows near-duplicates, the culprit is usually case or invisible spaces. Blank lines are treated like any other line, which means only the first empty line survives. The original order is kept, and the tool reports how many lines it dropped. Would a case-insensitive option help with your list?

Popular calculators

All Calculators