GlobalKit

Remove Duplicate Lines

Remove duplicate lines from a list, keep the first or last occurrence, and ignore letter case, surrounding spaces and invisible characters if you need to.

Up to 500,000 characters. Your text stays in your browser.

When No, "Apple" and "apple" count as the same line.

Ignores spaces, tabs, non-breaking spaces and zero-width characters at the start and end of each line; kept lines are output trimmed.

When Yes, empty and whitespace-only lines are never removed as duplicates.

Matches letters written as one character or as a base letter plus a combining mark (for example ş).

Total lines
0
Unique lines
0
Removed lines
0

How it works

Paste your list, one item per line. The tool reads it top to bottom, keeps a line the first time it sees it and drops every later line that matches. The counts under the result show the total, unique and removed lines.

Each line is turned into a comparison key before it is looked up, in this order:

  1. Surrounding spaces (if Ignore surrounding spaces is on): spaces, tabs, non-breaking spaces and the zero-width characters U+200B, U+200C and U+200D are removed from both ends. The kept line is also output without them.
  2. Unicode form (if equivalent forms are treated as equal, on by default): the key is normalised to NFC, so "ş" as one character matches "s" followed by a combining cedilla, and "ü" matches "u" plus a combining diaeresis.
  3. Letter case (if Case sensitive is No): the key is lower-cased with the rules of the selected language.

Only the key is changed. The output is the original text of the line that was kept. With Last occurrence the scan runs from the bottom, so the last copy of every line survives, and the list is then put back in order.

Line breaks of any kind (Windows CRLF, Unix LF, old Mac CR, and the Unicode line and paragraph separators) end a line, and the result is joined with plain LF. One break at the very end of the text does not create an extra empty line.

Examples

Input linesSettingsResult
pear
apple
pear
fig
apple
First occurrencepear
apple
fig
pear
apple
pear
fig
apple
Last occurrencepear
fig
apple
Apple
apple
APPLE
Case sensitive: No, firstApple
Apple
apple
APPLE
Case sensitive: No, lastAPPLE
a
"a" with a trailing space
Defaultsboth lines stay (2 unique)
a
"a" with a trailing space
Ignore surrounding spaces: Yesa
İstanbul
istanbul
ISTANBUL
Case sensitive: No, Turkish ruleİstanbul
ISTANBUL
İstanbul
istanbul
ISTANBUL
Case sensitive: No, English ruleİstanbul
istanbul
ş (U+015F)
s + U+0327
Equivalent Unicode forms: Yesone line, the first
a
(empty)
a
(empty)
b
Keep empty lines: Yesa
(empty)
(empty)
b
a
(empty)
a
(empty)
b
Keep empty lines: Noa
(empty)
b

Why the casing language is a setting. In the Turkish rule "I" is the capital of the dotless "ı" and "İ" is the capital of "i". So "İstanbul" and "istanbul" are the same word, while "ISTANBUL" lower-cases to "ıstanbul", which is a different key. Under the English rule "I" becomes "i", so "ISTANBUL" matches "istanbul", but "İ" turns into an "i" with a combining dot and no longer matches. Pick the rule of the language your list is written in.

Language-specific limits. Lower-casing is not full case folding. In German, "STRASSE" and "Straße" stay different lines, because ß is not turned into "ss", and a Greek final sigma "ς" does not match "σ".

Things to watch for

Frequently asked questions

Last updated: 10/11/2026

Related tools