Remove Duplicate Lines

Remove repeated lines from a block of text, keeping only the first occurrence of each.

How to Use the Remove Duplicate Lines Tool

  1. Paste your text into the box, with one item per line.
  2. Choose whether comparison should be "Case Sensitive" and whether to "Trim Whitespace Before Comparing".
  3. Click "Remove Duplicates" to see the de-duplicated list and how many lines were removed.

How Duplicates Are Detected

The text is split at every line break. The tool then walks down the list from top to bottom and keeps a record of every line it has already seen. A line is written to the result only if an equal line has not appeared above it. This means:

  • The original order is kept. Nothing is sorted, so the first occurrence stays in its original position.
  • Only whole lines are compared. Repeated words inside a line, or a line that merely contains another, are left alone.
  • Empty lines count as lines too. After the first blank line, later blank lines are treated as duplicates and removed, which also tidies up extra spacing.
  • The two options only change how lines are compared. The line that is kept is copied exactly as you typed it, with its original spaces and capital letters.

Worked Example: How the Options Change the Result

Suppose you paste these 7 lines: Mumbai, Delhi, mumbai, "Pune " (with a trailing space), Delhi, Pune, Chennai. The number of lines removed depends on the two checkboxes:

Case SensitiveTrim WhitespaceLines keptRemoved
OnOnMumbai, Delhi, mumbai, Pune, Chennai2
OnOffMumbai, Delhi, mumbai, Pune, Pune, Chennai1
OffOnMumbai, Delhi, Pune, Chennai3
OffOffMumbai, Delhi, Pune, Pune, Chennai2

With trimming off, "Pune " and "Pune" look identical on screen but are different strings, so both survive. For most lists, keeping trimming on and case sensitivity off gives the cleanest result.

Common Uses and Things to Watch

  • Cleaning email or mobile number lists merged from several spreadsheets before sending an invite or SMS.
  • Removing repeated keywords, URLs or product codes copied from reports.
  • Checking a roll-number or attendance list for entries typed twice: the "Duplicate lines removed" count tells you how many repeats there were.
  • Formatting differences defeat matching. "98765 43210" and "9876543210", or "Ltd." and "Limited", are different lines. Standardise the format first, for example with the Text Formatter.
  • If you copy columns from a spreadsheet, only identical whole rows are removed. Copy just the column you want to de-duplicate.

Frequently Asked Questions

It compares each line's text to every line seen so far, and removes any line that repeats an earlier one, keeping only the first occurrence.

When enabled, 'Hello' and 'hello' are treated as different lines. When disabled, they're treated as duplicates regardless of capitalization.

When enabled, leading/trailing spaces are ignored when comparing lines, so ' Hello' and 'Hello' are treated as duplicates, though the original line is kept as-is in the output.

No. Lines stay in their original order and each one is kept at the position where it first appears. If you also want the list in alphabetical order, run the result through the Text Sorter.

An empty line is compared like any other line, so only the first blank line survives and the rest are counted as duplicates. If you need paragraph spacing preserved, de-duplicate a plain one-item-per-line list instead.
No ratings yet — be the first!
Rate this calculator:
Was this tool helpful?