Sort lines alphabetically
Paste any list of lines and sort them alphabetically in one click. Choose A–Z or Z–A, optionally remove duplicates, trim whitespace, and remove empty lines. The sorted output appears instantly. All processing runs locally in your browser.
Input
Output
SORT OPTIONS
How it works
The input is split on newlines to produce an array of lines; a final newline does not add an empty line. Trim whitespace applies String.trim() to each line. Remove duplicates uses a Set keyed on the lowercased line to preserve the first occurrence. Keep original order skips sorting. The other sort modes use Array.sort() with an Intl.Collator for alphabetical ordering, the number each line starts with for numeric ordering, or a character count from Intl.Segmenter for length-based modes. Shuffle uses the Fisher-Yates algorithm with Math.random(). The result array is joined back with newlines. All processing runs in JavaScript in your browser.
Processing runs in your browser
All processing happens locally in your browser tab. Our servers are not involved at any point.
Related operations
For swapping recurring substrings across the list, try find and replace. To compare two sorted lists side by side, use text diff. For checking item counts after deduplication, see the word counter.
Frequently asked questions
- How does alphabetical sorting work?
- Lines are sorted using the browser's locale comparison with case-insensitive matching, so capitalisation does not affect the order. The sort is stable: lines with equal values keep their original relative order.
- Does it sort case-sensitively?
- Both the A–Z and Z–A sorts are case-insensitive, so 'Apple' and 'apple' are treated as equal and grouped together regardless of their capitalisation.
- Can I sort a list with numbers?
- Yes. Choose Numeric to sort lines by the number they start with, so '9' comes before '10'. Minus signs and decimal points are understood, so '-5' and '1.5' land in the right place; thousands separators such as '1,000' are not. Lines that do not start with a number follow in A–Z order. The A–Z sort compares numbers as text, so there '10' comes before '9'.
- How are accented letters sorted?
- The A to Z sort compares lines with Intl.Collator at base sensitivity, so accented and plain letters compare as equal (é sorts with e) and letter case is ignored. Lines that compare as equal keep their original order.
Last reviewed September 30, 2026
Other pages for this tool
Related tools
- Background reading: Complete guide to text tools