Sort Text Lines
Sort Text Lines is a free online tool that helps you alphabetize and reorder a list of lines instantly. Paste a list, choose how to sort it, and copy the cleaned-up result. Everything updates live as you type or change an option.
Input lines
0
Output lines
0
Removed
0
How It Works
Your text is split into individual lines on every line break. The tool then applies your cleanup options in order -- trimming whitespace, dropping blank lines, then removing duplicates -- and finally sorts whatever lines remain. The result is joined back together with one line per item and shown in the output box. All of this happens in your browser the moment you change anything, so there is no Sort button to press for normal sorting. Shuffle is the one exception: it deliberately randomizes order each time you click it.
Alphabetical sort
Compares lines as text. With case-insensitive off, capital letters sort before lowercase ones because of their underlying character codes. Turn case-insensitive on for everyday A-Z order.
Numeric / natural sort
Detects numbers inside each line and orders them by value, so file2 comes before file10. Ideal for file names, versions, and mixed lists.
Sort by length
Orders lines by character count, shortest to longest (or the reverse with Z to A). Lines of equal length keep their original relative order.
Worked Examples
Alphabetize names (case-insensitive)
Input:
banana Apple cherry apple
With A to Z, case-insensitive, and remove duplicates on, the output is:
Apple banana cherry
One duplicate (apple matching Apple) is removed and the count shows 1 removed.
Natural sort of versions
Input:
v1.10 v1.2 v1.9
Plain alphabetical sort would put v1.10 before v1.2. With numeric / natural sort, the output is correctly ordered:
v1.2 v1.9 v1.10
Options Reference
| Option | What it does |
|---|---|
| A to Z / Z to A | Sets ascending or descending order for the current sort mode. |
| Alphabetical | Standard text comparison, character by character. |
| Numeric / natural | Orders embedded numbers by value, so 2 comes before 10. |
| By length | Sorts by number of characters per line instead of content. |
| Case-insensitive | Ignores upper/lower case when sorting and when matching duplicates. |
| Trim each line | Removes leading and trailing spaces and tabs from every line. |
| Remove blank lines | Drops empty or whitespace-only lines before sorting. |
| Remove duplicates | Keeps the first occurrence of each unique line; shows how many were removed. |
| Reverse order | Flips the final result, after sorting (or shuffling) is applied. |
| Shuffle / randomize | Ignores sorting and produces a fresh random order using a Fisher-Yates shuffle. |
Tips
- Clean before sorting. Turn on Trim and Remove blank lines when pasting from spreadsheets or PDFs, where stray spaces and empty rows are common.
- Dedupe a list fast. Combine A to Z, Case-insensitive, and Remove duplicates to get a clean, unique, alphabetized list in one step.
- Natural sort for files. Use Numeric / natural when sorting file names or version strings so
2does not end up after10. - Reverse vs Z to A. Z to A sorts descending; Reverse flips whatever the current result is. Combining both can re-sort then re-flip, which is occasionally useful.
- Randomize repeatedly. Each click of Shuffle gives a new order, so you can keep clicking until you like the arrangement.
Related Tools
- Duplicate Line Remover -- strip repeated lines without changing order
- Text Reverser -- reverse text by characters, words, or lines
- Text Case Converter -- change a list to upper, lower, or title case
- Line Numberer -- add line numbers to a list of lines
- Word Counter -- count words, characters, and sentences
Privacy & Limitations
- Client-side only. All sorting runs in your browser with JavaScript. No text is uploaded, stored, or logged, and no cookies track your input.
- Lines, not paragraphs. Each line break starts a new item. Word-wrapped paragraphs are still single lines until a real line break is present.
- Locale-aware sorting. Comparison uses your browser's locale rules, so accented characters and non-English alphabets sort according to your system settings, which may differ between devices.
- Large lists. Extremely long lists may sort slowly on older hardware, but everything stays on your device.
Related Tools
View all toolsAnagram Checker
Check if two words or phrases are anagrams
Word Counter
Count words, characters, and sentences
Keyword Density Calculator
Analyze keyword frequency and density for SEO
Text Case Converter
Convert text to upper, lower, title, or sentence case
Slug Generator
Turn text into a clean URL slug
Reading Time Estimator
Estimate reading time from word count
Sort Text Lines FAQ
How do I alphabetize a list of lines?
Paste your list into the input box, then choose the A-Z direction. Each line is treated as one item and sorted into alphabetical order. The sorted result appears instantly in the output box on the right (or below on mobile). Use the Copy button to copy the result.
What is the difference between case-sensitive and case-insensitive sorting?
By default, many sorts treat uppercase letters as coming before lowercase letters because of their character codes (so 'Zebra' sorts before 'apple'). Turn on case-insensitive sorting to ignore letter case, so 'apple', 'Banana', and 'cherry' sort the way you would expect alphabetically regardless of capitalization.
What is numeric or natural sort?
A plain alphabetical sort compares text character by character, so 'item10' comes before 'item2' because '1' is less than '2'. Natural (numeric) sort detects numbers inside the text and orders them by value, so 'item2' correctly comes before 'item10'. Use it for file names, version numbers, and any list mixing text and numbers.
How do I remove duplicate lines?
Turn on 'Remove duplicate lines'. The tool keeps the first occurrence of each unique line and drops the rest. When combined with case-insensitive mode, lines that differ only by capitalization are also treated as duplicates. The counter shows how many duplicates were removed.
Does sorting remove blank or empty lines?
Only if you turn on 'Remove blank lines'. By default, blank lines are kept and grouped together (they sort to the top in A-Z order). Enabling the option strips out any line that is empty or contains only whitespace before sorting.
How does 'sort by line length' work?
Instead of comparing the text itself, this option orders lines by how many characters each line contains, from shortest to longest (or longest to shortest with Z-A). Lines of equal length keep their original relative order. It is handy for finding the longest or shortest entries in a list.
What does shuffle / randomize do?
Shuffle ignores all sorting and puts the lines in a random order using an unbiased Fisher-Yates shuffle. Each click of the Shuffle button produces a fresh random arrangement. It is useful for randomizing names, picking an order, or creating quiz orders. Other cleanup options like trim and remove duplicates still apply first.
Does trimming change my lines?
Trimming removes leading and trailing spaces and tabs from each line, but leaves the words inside untouched. It is useful when copied lists have inconsistent indentation. The line content and internal spacing are preserved.
Is there a limit to how many lines I can sort?
There is no fixed limit. Because everything runs in your browser, very large lists (hundreds of thousands of lines) may sort slowly on older devices, but typical lists of names, URLs, words, or data rows sort instantly.
Does this tool send my text anywhere?
No. All sorting and processing happens entirely in your browser using JavaScript. Your text is never uploaded, stored, or logged. You can even use the tool offline once the page has loaded.