Remove Duplicate Lines
Remove duplicate lines from a list and keep the original order, ignoring case or spaces, with sorting, copy and download.
- Free
- No sign-up
- Runs in your browser
Remove Duplicates
Runs in your browser. Your inputs never leave your device.
In short
Quick Answer
Paste your list, one item per line, and every repeated line is removed while the first occurrence of each stays in its original position. Turn on Ignore case to treat 'Apple' and 'apple' as the same, or Trim spaces to ignore spaces at the start and end of lines. The tool shows how many duplicates were removed, and you can copy or download the result.
Step by step
How to Use
- Paste your list. Paste the text with one item per line.
- Choose how to compare. Turn on Ignore case or Trim spaces if those differences should not count.
- Choose what to keep. Keep the first or last copy, remove empty lines, and sort if you want.
- Copy or download. Copy the cleaned list or download it as a text file.
Which Options to Use
| Your list | Suggested options |
|---|---|
| Email addresses | Ignore case, Trim spaces, Trim output, Remove empty lines |
| Keywords or tags | Ignore case, Trim spaces, sort A to Z |
| Product codes or IDs | Trim spaces only (case can matter) |
| Log lines or exports with newer entries lower down | Keep last occurrence |
| Code or configuration | No options: every character counts |
The result keeps each line exactly as you wrote it unless you turn on Trim output. That way an indented line or a line with meaningful trailing spaces is not changed just because spaces were ignored while comparing.
Other Ways to Remove Duplicates
- Command line:
sort -u file.txtremoves duplicates but sorts the file;awk '!seen[$0]++' file.txtkeeps the original order. - Spreadsheets: Excel's Remove Duplicates command or the UNIQUE function, and UNIQUE in Google Sheets.
- Comparing two lists: to see what changed between two versions rather than what repeats, use the text diff checker.
Your text stays on your device: it is processed in the browser and is not saved or sent anywhere.
The math
How Duplicates Are Found
Keep a line if its comparison key has not been seen before · key = line (trimmed if Trim spaces) (lower-cased if Ignore case)
The lines are read from top to bottom. Each line gets a comparison key: the line itself, with surrounding spaces removed if Trim spaces is on and lower-cased if Ignore case is on. The first line with a given key is kept exactly as you typed it; later lines with the same key are dropped. With Keep last, the list is read from the bottom instead, so the last occurrence survives, still in its original position. Sorting, if chosen, happens after duplicates are removed and is number-aware, so item2 comes before item10.
- Ignore case: 'Apple', 'APPLE' and 'apple' count as one value.
- Trim spaces: Spaces and tabs at the start or end of a line are ignored when comparing. Turn on Trim output to remove them from the result as well.
- Keep first / last: Which copy of a repeated line stays in the list.
Examples
Worked Examples
Case-sensitive
Lines: a, b, a, B
- The second 'a' repeats the first and is removed
- 'B' is different from 'b' when case matters
Result: a, b, B (1 duplicate removed)
Ignore case
Lines: a, b, a, B · Ignore case: on
- 'a' repeats, and 'B' matches 'b'
Result: a, b (2 duplicates removed)
Trim spaces
Lines: ' a' (with a leading space), 'a' · Trim spaces: on
- Both lines compare as 'a', so the second is removed
- The kept line is written as typed (' a'); with Trim output on it becomes 'a'
Result: One line: ' a', or 'a' with Trim output
Watch out
Common Mistakes to Avoid
- Missing duplicates that differ only by spaces: 'apple' and 'apple ' with a trailing space look the same but are different strings. Turn on Trim spaces when your list was copied from a spreadsheet or document.
- Merging values that should stay separate: Ignore case is right for email addresses and most words, but not for case-sensitive data such as passwords, IDs or file names on Linux.
- Expecting the list to be sorted: By default the original order is kept. Choose A-Z or Z-A if you want a sorted list.
- Losing the last, most recent entry: If later lines are newer versions of earlier ones (for example a log or an export), choose Keep last so the most recent copy survives.
- Treating blank lines as data: Several blank lines count as duplicates of each other, so one blank line can remain. Turn on Remove empty lines to drop them all.
FAQ
Frequently Asked Questions
How do I remove duplicate lines from a list?
Paste the list into the box. Repeated lines are removed straight away, the first copy of each line stays in its original place, and the count of removed duplicates is shown.
Does this keep the original order?
Yes. Unless you choose a sort order, the kept lines stay in the order you pasted them.
Can I remove duplicates ignoring case?
Yes. Turn on Ignore case and lines that differ only in capital letters, such as 'Paris' and 'paris', count as the same.
How do I keep the last occurrence instead of the first?
Choose Keep last. The last copy of each line is kept, in the position where it appears.
Can I sort the lines and remove duplicates at the same time?
Yes. Choose A-Z or Z-A. Duplicates are removed first, then the remaining lines are sorted, with numbers in natural order.
How do I remove duplicates in Excel instead?
In Excel, select the column and use Data > Remove Duplicates, or =UNIQUE(range) in Excel 365. This tool is quicker for lists you have copied as plain text.
Is my list uploaded anywhere?
No. The lines are processed in your browser and are not sent, stored or added to the page address.
References