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
No line occurs more than once.
| Count | Line |
|---|
Runs in your browser. Nothing you enter is sent anywhere. How to check
1.How to use
- Paste your lines, one item per line. The result appears as you type.
- Choose options if lines that differ only in case or spaces should count as the same.
- Copy the result, or press Download to save it as
unique-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
awk '!seen[$0]++' file.txtkeeps the first occurrence in the original order, like this tool with no options.awk '!seen[tolower($0)]++'matchesIgnore case for ASCII text.sort -u file.txtremoves duplicates but sorts the lines, so the original order is lost.uniq file.txtremoves only repeats next to each other, likeOnly adjacent duplicates.uniq -ialso ignores case.
This tool recognizes \n, \r\n and \r line breaks, and the result uses the line break found first in your text.
5.Limits
- Input up to 10 MB or 1,000,000 lines. Above 1 MB, press Remove duplicates instead of the automatic run.
- No Unicode normalization:
étyped as one character differs fromefollowed by a combining accent, even though they look the same. - The Duplicates tab shows the first 1,000 repeated lines; the counts cover all of them.
- Text only: paste the lines. File upload is not available.
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.