Developer Toolbox
New here? Take a 30-second tour of how this page works.

Remove Duplicate Lines

Remove repeated lines and keep the first of each, in the original order.

First occurrence kept · original order · limit 10 MB or 1,000,000 lines

Options

Runs in your browser. Nothing you enter is sent anywhere. How to check

1.How to use

  1. Paste your lines, one item per line. The result appears as you type.
  2. Choose options if lines that differ only in case or spaces should count as the same.
  3. Copy the result, or press Download to save it asunique-lines.txt.

The first occurrence of each line is kept, exactly as you entered it, and everything stays in its original order. The Duplicates tab lists each repeated line with the number of times it occurs.

2.Examples

An email list with case differences

The list ana@example.com, Ben@Example.com,ana@example.com, ben@example.com, carla@example.com,ANA@EXAMPLE.COM has six lines. With the default exact comparison, only the second ana@example.com is removed. With Ignore case, three lines remain: ana@example.com, Ben@Example.com andcarla@example.com.

Log lines with repeats next to each other

A log has GET /health 200 three times, then POST /login 401, thenGET /health 200 again. With Only adjacent duplicates, the result is GET /health 200, POST /login 401, GET /health 200: each run of repeats becomes one line, and the timeline stays readable. Without the option, the last GET /health 200 is removed too.

3.Options explained

Options change only how lines are compared. The lines you get back are never changed.

Ignore case

Apple then apple gives Apple. Case follows Unicode rules, so Straße and STRASSE also count as the same.

Ignore leading and trailing spaces

user=alice then user=alice (with a trailing space) givesuser=alice. Spaces and tabs at the start and end of a line are ignored; spaces inside the line still count.

Remove empty lines

a, empty, b, empty, empty, c gives a,b, c. Without this option, empty lines are treated like any other line, so the result is a, empty, b, c. A line of only spaces counts as empty when spaces are also ignored.

Only adjacent duplicates

a, a, b, a gives a,b, a: a line is removed only when it equals the line directly before it. The Duplicates tab still counts every occurrence.

4.Command-line equivalents

This tool recognizes \n, \r\n and \r line breaks, and the result uses the line break found first in your text.

5.Limits

6.FAQ

Does it keep the first or the last occurrence?

The first, in its original position. To keep the last occurrence on the command line, usetac file.txt | awk '!seen[$0]++' | tac.

Why does sort -u change the order?

It sorts the lines first, so repeats end up next to each other, then keeps one of each. This tool remembers every line it has seen instead, so nothing needs to move.

Is my text uploaded?

No. Duplicate removal runs in your browser. The privacy pageshows how to confirm this in your browser's Network tab.