Sort Text Lines
The free online tool to sort the lines of your text.
Alphabetize A to Z or Z to A, sort by length, optionally remove blanks and duplicates, live as you type, then copy or download.
Sorted Text
What does Sort Text Lines do?
Sort Text Lines is a free tool that puts the lines of your text in order. Type or paste your lines into the box above, one item per line, and the sorted version appears instantly in the result panel, with no button to press and no signup. Then copy the result to your clipboard or download it as a plain text file. It runs entirely in your browser, so your text never leaves your device.
There are four orders to choose from. A to Z, the default, alphabetizes the lines. Z to A sorts them in reverse. Shortest first and Longest first order the lines by their length, and when two lines are the same length they fall back to alphabetical order so the result is always predictable. The sort is stable, which means lines that compare equal keep their original order, so you get the same output every time.
A few options fine-tune the comparison. By default the alphabetical sort is case-insensitive, so “apple” and “Apple” sit together as you would expect; turn on Case sensitive to make uppercase letters sort before lowercase. Ignore leading and trailing spaces sorts by the trimmed text while keeping each line’s original spacing. Remove blank lines drops empty lines before sorting, and Remove duplicates strips repeated lines as part of the sort, so you can alphabetize and deduplicate a list in one step.
Sorting lines is handy in many places: alphabetizing a list of names, words or book titles, organizing keywords or tags, putting CSV rows in order before you import them, and ordering by length to spot the longest or shortest entries. It works well with the other line tools. To remove repeats without reordering, use remove duplicate lines (this tool can also dedupe while it sorts). To tidy messy spacing, use remove extra spaces, and to count how many lines you have, use the line counter. Everything runs in your browser with no account and nothing to install. Paste your lines above to sort them instantly, then copy or download the result.
Sort Text Lines Examples
| Order | Input | Output |
|---|---|---|
| Alphabetical (A to Z) | banana apple cherry | apple banana cherry |
| Reverse (Z to A) | banana apple cherry | cherry banana apple |
| Shortest first | kiwi fig banana | fig kiwi banana |
| Sort and remove duplicates | pear apple pear | apple pear |
| Sort and drop blank lines | b a | a b |
*Every row is produced by the same engine this page uses. The lines in the input column are real; the output column is what the tool returns.
Features of Our Sort Text Lines Tool
A-Z & Z-A
Line Length
Option
Duplicates
You Type
Download
& Private
Frequently Asked Questions
Click any question to read the answer.
How do I alphabetize a list of text?
Paste or type your text into the box above, one item per line, and the sorted version appears instantly in the result panel below. The default order is A to Z, so a list of names or words is alphabetized straight away. For example the lines "banana", "apple", "cherry" become "apple", "banana", "cherry". Then use Copy to put the result on your clipboard, or Download to save it as a plain text file.
How do I sort lines from Z to A?
Choose "Z to A" in the Order selector. The lines are sorted in reverse alphabetical order, so the list runs from the last item to the first. Everything else works the same way, and you can combine it with the other options, such as removing blank lines or duplicates.
Can I sort lines by length?
Yes. Choose "Shortest first" to sort from the shortest line to the longest, or "Longest first" for the reverse. When two lines are the same length, they fall back to alphabetical order, so the result is always predictable. Length is measured by the number of characters in the line.
Is the sort case-sensitive?
By default no, so "apple" and "Apple" are ordered together as you would expect in a normal alphabetical list. Turn on "Case sensitive" to take capitalisation into account; uppercase letters then sort before lowercase letters, following their character codes.
Can it remove duplicates while sorting?
Yes. Turn on "Remove duplicates" and repeated lines are removed as part of the sort, so you get a clean, ordered list in one step. It uses the same rule as the Remove Duplicate Lines tool, honouring the case option, so it pairs naturally with sorting.
Does it change or keep my actual lines?
It keeps your lines exactly as they are and only changes their order. No text inside a line is altered. If you turn on the cleanup options it may drop blank lines or duplicates, but the lines it keeps are unchanged, including their original spacing and capitalisation.
What about extra spaces around a line?
By default leading and trailing spaces count, so " apple" with a leading space sorts by that space. Turn on "Ignore leading/trailing spaces" to sort by the trimmed text instead. Only the comparison is trimmed; the line that is kept keeps its original spacing.
Is my text stored when I use this tool?
No. The tool runs entirely as JavaScript inside your browser, so your text is never uploaded, logged, or sent to a server. The page keeps working offline once it has loaded, and nothing you type leaves your device. You can sort a private list with no privacy risk at all.