Text
Sort & Dedupe Lines
Sort lines of text alphabetically, remove duplicates, empty lines, and extra whitespace.
This tool sorts a list of lines alphabetically and removes duplicates and blank lines — a routine cleanup that's slow and error-prone to do by hand.
How to use it
- Paste text (one value per line) and sorting and deduplication happen instantly.
- Pick an order (ascending, descending, or natural) depending on the kind of data.
- Turn on removal of blank lines and extra whitespace to get a clean result in one pass.
Common uses
- Turning a list of email addresses or usernames into a unique, sorted list before importing it.
- Sorting a list of files or versions with numeric parts in natural order (file2 before file10).
- Quickly cleaning up a list copied from a spreadsheet or document, removing duplicates and stray blank lines.
Things to keep in mind
Plain alphabetical sorting puts "file10" before "file2", since it compares strings character by character — natural sort is needed for the expected order with numbers.
Duplicate removal is case-sensitive by default — "Text" and "text" count as different lines unless the text is normalized to one case first.
Article about this tool: Sorting and deduplicating lines: why it matters
Frequently asked questions
What's the difference between case-sensitive and case-insensitive sorting?
With "Case-insensitive" off, uppercase and lowercase letters are sorted separately by character code; turned on, it compares lines regardless of case, bringing "Apple" and "apple" together.
How are duplicates, blank lines, and whitespace handled?
Two identical lines (according to the chosen case option) are considered duplicates and only the first is kept; "Trim whitespace" removes leading and trailing spaces before sorting, and "Remove blank lines" eliminates lines with no visible character.
Are my text lines sent to a server?
No, sorting and deduplication happen entirely in your browser in JavaScript — no data is transmitted elsewhere.
Why does "10" end up before "9" in alphabetical sorting?
Alphabetical (lexicographic) sorting compares strings character by character as text, not as numbers: "1" is lexicographically smaller than "9", so "10" comes before "9". For numeric order, the strings need to be parsed as numbers first.
Can I sort using natural order (natural sort)?
Natural sort recognizes digit runs within a string as numbers while comparing the rest as text — that's why "file2.txt" ends up before "file10.txt", which is useful for filenames or versions with a text prefix.