Line Dedupe & Sort

Remove blank lines and duplicate lines, optionally sort alphabetically

Line dedupe and sort: the boundaries of exact matching and common surprises

Dedupe is "exact match", not "looks the same"

To decide whether two lines are duplicates, the tool does a character-by-character comparison. So these "look-alike" cases are not removed:

Actual content of the two linesJudged duplicate?Reason
apple and apple (trailing space)NoTrailing whitespace is part of the content
apple and AppleNoCase-sensitive
café and café (combining accent)NoDifferent Unicode code-point sequences, identical rendering
a b and a  b (two spaces)NoDifferent count of whitespace characters

So the most common reason "dedupe did not work" is trailing whitespace or invisible characters. Text copied from a web page or a PDF is especially likely to carry them. The recommended order is: remove blank lines and trim first, then dedupe. This tool offers a "remove blank lines" toggle and compares by exact line content when judging duplicates.

Also note: a field that itself contains a newline is not "one line". When copying from CSV, if a field has an internal newline (and was not quoted), it is split into multiple lines, and dedupe then works at the wrong granularity.

Which one is kept

On a duplicate, the tool keeps the first occurrence and discards the later ones. If the surrounding context carried position information, the deduped result loses it.

When you need "keep the last" or "pick one by a rule", line dedupe is insufficient — that is data dedupe, which groups by a key field and takes one row, using SQL's DISTINCT ON or row_number(), or a script.

Two notions of sorting

The tool can sort alphabetically, and here too there are details:

When you see "the sort is wrong", first decide which kind it is. The dedupe-plus-sort combination is most often used to organize keywords, domains, emails, IPs, and import whitelists — here the "duplicates" are usually format differences (one with www, one without; one with a trailing slash, one without), and you must normalize before dedupe or it will not clean up fully.

Actual uses of dedupe

The last point deserves emphasis: dedupe hides conflicts. Two rows with the same name but different values are not "duplicates"; after dedupe you lose one of them and will not know which. When merging config, find the same-name-different-value items and confirm them by hand before doing any pure deduplication.

How to use the tool

Paste text with one item per line, toggle "remove blank lines", "dedupe", and "sort" as needed, click Process, then use the Copy button to take the result. The three toggles combine freely — for example, to remove only blank lines while keeping duplicates, uncheck dedupe. The whole operation happens in the page; nothing is uploaded.

FAQ

What are the sorting rules?

Uses JS default string sorting, comparing by Unicode code points and case-sensitive. For Chinese pinyin sorting, pre-process with another tool first.

Does dedupe keep the first or last occurrence?

Keeps the position of the first occurrence; subsequent duplicate lines are removed.