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, andAPPLEare three different lines unless Ignore case is on. With it on, the first spelling encountered is the one kept. - Whitespace.
appleandapplewith 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
.gitignoreentries 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.