Sort & Remove Duplicate Lines
Sort lines naturally or alphabetically, remove duplicates keeping the first or last, reverse, or shuffle, with line endings preserved.
Local workspace
Named projects in IndexedDB · Local only — never synced to our servers. Worksp…
Batch workspace
Format multiple files locally in one run.
Sorting and deduping lines is the kind of task that gets done with a half-remembered sort | uniq pipeline, which silently changes the parts you cared about: uniq only removes adjacent duplicates, and a plain sort puts file10 before file2. This tool sorts naturally by default, removes duplicates anywhere in the list while letting you keep the first or last copy, and leaves CRLF endings and a trailing newline as it found them. Trimming and case sensitivity are separate switches, so you can decide whether lines that differ only in spacing or capitalization count as the same.
Common errors and fixes
The output lost my blank lines
Remove empty lines is on by default. Turn it off to keep them, though sorting will group them together.
Duplicates weren't removed
The lines differ invisibly, usually by trailing whitespace or capitalization. Turn on Trim whitespace, and leave Case sensitive off.
Line endings changed after sorting
The output uses the endings the input had, and a file with mixed endings is normalized to CRLF if any CRLF is present. Normalize the file first if that matters.
Version numbers sort in the wrong order
Alphabetical order puts 1.10 before 1.9. Choose natural order, which compares the numbers by value.
Options
| Option | Description |
|---|---|
| Operation | Sort can also drop duplicates. Remove duplicates on its own keeps the original order. |
| Order | Natural order compares embedded numbers by value, which is what you want for filenames and versions. |
| Descending | Reverses the sort order. |
| Also remove duplicates | Drops repeated lines while sorting. |
| Keep | Which copy of a repeated line to keep. Last is useful when later lines override earlier ones. |
| Case sensitive | Off, Apple and apple count as the same line and sort together. |
| Trim whitespace | Removes leading and trailing spaces before comparing, so lines that differ only in spacing count as duplicates. |
| Remove empty lines | Turn off to keep blank lines in the output. |
FAQ
What does natural order do differently?
It compares numbers inside the text by value, so file2 comes before file10. Alphabetical order compares character by character, which puts file10 first because 1 sorts before 2.
Should duplicates keep the first or the last copy?
Keep first preserves the earliest position, which suits lists you're deduping. Keep last suits config files and environment variables, where a later line overrides an earlier one.
Are blank lines and indentation preserved?
Blank lines are dropped by default and you can keep them with an option. Indentation is kept unless you turn on trimming, which removes leading and trailing spaces before comparing.
Is the comparison case sensitive?
Not by default, so Apple and apple are treated as the same line. Turn on Case sensitive for exact matching, which also separates them when sorting.
How random is the shuffle?
It uses a Fisher-Yates shuffle with the browser's cryptographic random source and rejection sampling, so every ordering is equally likely rather than merely scrambled.