Skip to content
ToolkitHub

Remove Duplicates in List

Remove duplicate lines from text

Guide

Deduplicating a list line by line

By Logappradeep · ServiceNow developer

Lists collect duplicates naturally: merged email exports, keyword research from several tools, IDs copied from multiple queries, repeated log lines, or a hosts file edited by many people over the years. This tool keeps the first occurrence of every line, removes later repeats, and preserves the original order of everything that remains.

How matching works

By default, lines are compared exactly, character for character. Two options relax that: Ignore case treats apple and Apple as the same line, and Trim whitespace ignores leading and trailing spaces and tabs (and trims the lines it keeps). Without them, some lines that look the same to you are different to the tool:

  • Case. apple, Apple, and APPLE are three different lines unless Ignore case is on. With it on, the first spelling encountered is the one kept.
  • Whitespace. apple and apple with a trailing space differ unless Trim whitespace is on. Text copied from spreadsheets and PDFs often carries invisible trailing spaces or tabs.
  • Look-alike characters. A non-breaking space, a zero-width space, or curly versus straight quotes make lines unequal even though they render identically. The Unicode encoder can reveal these.
  • Blank lines are treated like any other line, so multiple empty lines collapse to one. Use Remove Empty Lines to remove them entirely.

An example

alice@example.com
bob@example.com
alice@example.com
carol@example.com
bob@example.com

becomes:

alice@example.com
bob@example.com
carol@example.com

Order-preserving versus sorted deduplication

Command-line users often reach for sort -u, which deduplicates but also sorts, destroying the original order. The order-preserving equivalent is awk '!seen[$0]++', which keeps the first occurrence of each line exactly as this tool does. Preserving order matters when the list has a meaningful sequence, such as priority rankings, chronological events, or a playlist. If you want a sorted, unique list, deduplicate here and then run the result through Sort Lines.

Practical uses

  • Cleaning mailing lists before an import, so subscribers do not receive the same message twice.
  • Merging keyword or tag lists from several sources.
  • Reducing repeated error messages in logs to see each distinct problem once.
  • Building unique lists of IDs, SKUs, or URLs for a query or bulk operation.
  • Tidying configuration lists such as .gitignore entries or allowlists.
  • Checking how many distinct values a list really contains, using the count of removed lines.

Lists are processed in your browser, so customer emails and internal IDs never leave your machine.

Frequently asked questions

Is the comparison case-sensitive?

By default, yes: "Apple" and "apple" are kept as separate lines. Tick Ignore case to treat them as duplicates.

Why are some duplicates not removed?

They probably differ by invisible characters. Tick Trim whitespace to ignore leading and trailing spaces; non-breaking or zero-width spaces inside a line still count.

Does it change the order of my list?

No. Lines stay in their original order; only repeats after the first occurrence are removed.

Can I deduplicate comma-separated values?

The tool works line by line, so put each value on its own line first, for example by replacing commas with line breaks.