How to remove duplicate lines and sort a list
Updated · 3 min read
Lists collect duplicates: merged exports, copied columns, log files, keyword research. This tool removes repeated lines while keeping the original order, sorts what is left, and can show you exactly which lines repeat and how often — without uploading your data anywhere.
- Paste your list into the left box — one item per line — or upload a .txt or .csv file. The result updates as you type.
- Choose what to Keep: unique lines, only the lines that repeat, or only the lines that appear once.
- Pick a Sort order if you need one: A–Z, natural order (so
item 2comes beforeitem 10), by length, or by how often a line repeats. - Copy the result or download it as a text file. Turn on Show how many times each line appears to get a frequency count.
Example
Input
banana
Apple
cherry
apple
banana
item 10
item 2
cherryUnique, natural sort
Apple
banana
cherry
item 2
item 10Only repeats, with counts
2 banana
2 Apple
2 cherryApple and apple count as one line because the comparison ignores case by default, and banana matches banana once spaces are trimmed. Natural sorting puts item 2 before item 10.
Your data stays on your device. Everything runs in JavaScript inside this tab — nothing you paste is uploaded to DataSwitch Pro.
What people use it for
Clean email and contact lists
Merge several exports, paste them in, and remove the duplicates before an import or a send. With case-sensitivity off, Anna@Example.com and anna@example.com count as one address.
Find repeated values
Choose Only lines that repeat with counts on to see which IDs, orders or log messages occur more than once — useful before setting a unique key in a database.
Sort keywords, tags and names
Sort alphabetically or in natural order, then join the list with the Comma Separator when you need it on one line.
Compare two lists
Paste list A and list B together and keep Only lines that repeat to get the values that are in both; keep Only lines that appear once to get the values that are in just one of them (as long as neither list has internal duplicates).
Common problems and fixes
Two lines look the same but are not removed
They differ in something you cannot see: a trailing space, a tab, a non-breaking space or different letter case. Keep Trim spaces on, turn on Treat repeated spaces as one, and leave Case-sensitive off.
Numbers sort as 1, 10, 2
That is plain alphabetical order. Choose Natural sorting so numbers inside the text are compared by value: 1, 2, 10.
Whole rows are de-duplicated, not one column
This tool compares complete lines. To remove rows with the same value in one column of a CSV or Excel sheet, use Excel's Remove Duplicates (choose the column) or convert the file with CSV to JSON and filter it in code.
Accented letters sort in the wrong place
Sorting uses your browser's language rules, so é sorts next to e rather than after z. That is usually what people expect; plain byte order is what tools like the Unix sort command use with LC_ALL=C.
Do it in Excel, the command line or code
The tool above is the quickest for a one-off list. These do the same job inside a spreadsheet or a script.
Excel and Google Sheets
' Excel 365 / 2021 and Google Sheets: unique values, sorted
=SORT(UNIQUE(A2:A1000))
' Excel without UNIQUE: Data > Remove Duplicates
' Count how often a value appears
=COUNTIF($A$2:$A$1000, A2)Command line (Linux, macOS, Git Bash)
sort -u list.txt > unique.txt # sort and remove duplicates
awk '!seen[$0]++' list.txt > unique.txt # remove duplicates, keep order
sort list.txt | uniq -c | sort -rn # count repeats, most frequent firstPython
lines = open("list.txt", encoding="utf-8").read().splitlines()
unique = list(dict.fromkeys(l.strip() for l in lines if l.strip())) # keeps order
print("\n".join(sorted(unique, key=str.lower)))PowerShell
Get-Content list.txt | Sort-Object -Unique | Set-Content unique.txt
Guides for this tool
How to Remove Duplicates from a List
Excel, Google Sheets, Notepad++, the command line and Python — and how to find the repeats.
How to Convert a Column to a Comma-Separated List
Once the list is clean, join it for SQL WHERE IN, code or forms.
Frequently asked questions
How do I remove duplicate lines from a list?
Paste the list into the box on this page. Each line is compared with the others and only the first copy is kept, in the original order. Copy the result or download it as a text file.
Does it keep the original order?
Yes, unless you choose a sort order. The first time a line appears is where it stays; later copies are removed.
Is the comparison case-sensitive?
Not by default — Apple and apple are treated as the same line and the first spelling is kept. Turn on Case-sensitive to keep both.
How do I find which lines are duplicated?
Set Keep to Only lines that repeat and turn on Show how many times each line appears. Sort by Most repeated first to see the biggest offenders at the top.
How many lines can it handle?
Hundreds of thousands of lines on a normal computer. Everything runs in your browser, so the limit is your device's memory, not an upload size.
Is my list uploaded anywhere?
No. The tool runs entirely in this browser tab; nothing you paste or upload is sent to a server.