Sort & Dedupe Lines
Sort, dedupe, trim, shuffle, or reverse a list of lines. Natural sort for embedded numbers, case-sensitive toggle, blank-line removal.
Paste lines on the left.
Operations apply in order: trim → remove blank → dedupe → sort → reverse. All processing happens in your browser.
How to use
- Paste your list on the left.
- Pick a sort order and toggle the options you want (dedupe, trim, etc).
- Copy the output from the right panel.
About this tool
ShowHide
A grab bag for the things you'd do with sort | uniq | grep -v '^$' in a shell — alphabetical, descending, or natural sort (so 'item10' comes after 'item2', not after 'item1'); deduplicate (case-sensitive or not); trim whitespace; drop blank lines; reverse the result; or shuffle for a randomized order. Counts shown for input, output, and removed lines so you can see what changed.
Natural sort is the option worth knowing about, because plain alphabetical order treats a number as a string of digits. item2 sorts after item10 there, since the comparison stops at the first character that differs and 1 precedes 2. Natural sort reads runs of digits as numbers and puts them in the order a person expects, which matters for filenames, version strings and anything ending in a counter.
Alphabetical order is not one thing either. Sorting by code point puts every uppercase letter before every lowercase one, so Zebra lands above apple, and accented characters fall outside the basic range entirely. A locale-aware comparison folds case and treats é next to e, which is what a reader expects and what a naive sort does not do. The case-insensitive toggle here addresses the first half of that.
Deduplication keeps the first occurrence and runs before sorting, so the order of the input decides which duplicate survives. That is invisible when the lines are identical and matters when they differ only in case or in trailing whitespace: trimming before deduplicating collapses foo and foo into one entry, while doing it the other way round leaves both. The order of operations is doing real work.
The counts are the part to read. A dedupe that removes far more lines than you expected usually means whitespace or case was hiding duplicates you did not know about, and one that removes none when you expected some means the opposite.
Frequently asked questions
What's 'natural sort'?
Sort that understands embedded numbers: 'item2', 'item10' instead of 'item10', 'item2'. Uses Intl.Collator with numeric=true under the hood. Useful for filenames, version numbers, sequential IDs.
Is shuffle deterministic?
No — it uses Math.random() with the standard Fisher-Yates algorithm. Click 'shuffle' again to get a different order. If you need a seeded shuffle (for reproducible randomness), this isn't the tool.
Does dedupe preserve order?
If sort is 'none', yes — the first occurrence wins and the rest are dropped. If sort is set, dedupe happens before sort, so the output is the sorted set of unique lines.
What if I want to keep blank lines as separators?
Uncheck 'remove blank lines'. Blank lines are then kept, but dedupe still applies to them: every empty line is the same string (and with trim on, so is every whitespace-only line), so only the first survives. To keep every blank separator, turn off dedupe as well.
Related tools
Reverse Text
Reverse text four ways — by characters, word order, the letters inside each word, or line order. Works with emoji and any language.
Text
CSV Viewer & Sorter
View CSV / TSV data as a sortable, searchable table — open a file or paste rows, no spreadsheet required.
Text
Remove Line Breaks
Join wrapped lines back into clean, flowing text — strip the hard line breaks you get when copying from PDFs or emails, while keeping real paragraphs.
Text
Line Formatter — Add Prefix, Suffix & Join
Wrap each line with a prefix and suffix and join them with any separator, in your browser.
Text
Character & Word Counter
Count characters, words, sentences, lines, and bytes in real time.
Text
Case Converter
Convert text between UPPER, lower, Title, camelCase, snake_case and more.
Text
UUID Generator
Generate random version-4 UUIDs in bulk, with copy.
Developer