Sort Lines Alphabetically
Paste a list and sort it in one click: A to Z, Z to A, shortest first, longest first, or numerically. Case-insensitive by default, with the original lines untouched apart from their order.
Runs in your browser — your code and data never leave this device
How do I sort lines alphabetically online?
Paste your lines here: this free online tool sorts lines alphabetically, A to Z or Z to A, or by length — shortest first or longest first — or numerically, so 2 comes before 10. A case-sensitive option controls whether capitals sort before lowercase, and the result copies to the clipboard or downloads as a .txt file.
Related tools
How to use the Sort Lines Alphabetically
- Paste your lines into the Input box — one item per line — or click Sample to load an example list.
- Pick a sort order: A to Z, Z to A, shortest first, longest first, or numeric. Leave Case-sensitive off unless capital letters should sort separately.
- Click Sort Lines. The sorted list appears on the right, with each line unchanged apart from its new position.
- Copy the result or Download it as a text file.
For the full picture — alphabetical, length and numeric sorting, and why sorting makes duplicates visible — read our guide: How to Sort Lines Alphabetically (Free, A to Z and More).
What sorting a list actually does for you
Sorting turns a pile into a sequence you can use. An alphabetical list can be scanned in seconds, a sorted list of names makes duplicates obvious, and a sorted list of numbers shows the smallest and largest values at a glance. It is one of those small operations that people do dozens of times a week — preparing a guest list, tidying a keyword list, ordering file names — and doing it by hand is slow and error-prone.
Sorting also prepares lists for other tools. A sorted list can be compared line by line against another sorted list to find what changed, which is exactly how the Diff Checker works. And when two lists are both sorted, merging them without duplicates becomes a simple scan instead of a search. Sort first, then compare or merge — the order makes everything after it easier.
Alphabetical, length and numeric sorting explained
Alphabetical sorting compares letters from left to right, and by default it ignores case, so apple, Apple and APPLE sort together. Tick Case-sensitive if you want capital letters to sort before lowercase ones, the way a computer orders them by default. The comparison uses plain letter order, not the rules of any particular language, so accented letters sort by their base character in most browsers.
Length sorting orders lines by how many characters they contain, which is useful for finding the longest entries or the shortest ones — the longest product name, the shortest password candidate. Numeric sorting reads the number at the start of each line and orders by value, so 2 comes before 10, unlike plain alphabetical order where 10 comes first because 1 sorts before 2. Lines without a leading number sort after the numbers, alphabetically.
Sorting and duplicates go together
Sorting and removing duplicates are natural partners: after sorting, any repeated line sits directly next to its twin, which makes duplicates visible even without a tool. Run Remove Duplicate Lines first if you want a clean list in its original order, or sort first and then remove duplicates if you want a clean alphabetical list — either way the two operations combine into a properly tidied list.
One thing sorting never does is change the lines themselves. No text is added, removed or reformatted; only the order changes. If your list needs cleaning as well — extra spaces, stray blank lines, inconsistent capitalisation — run the Text Cleaner or the Case Converter before or after sorting, depending on whether you want the sort to see the cleaned text.
A to Z, Z to A, by length or numerically: five ways to sort
Sort list A to Z online free for the everyday job — names, words, items in a list — or flip to Z to A when the order runs the other way. Sorting by length puts the shortest lines first or the longest first, which is handy for picking the shortest label or the longest entry at a glance. Numeric sort treats the lines as numbers, so 2 comes before 10 — the order alphabetical sorting gets wrong, because it compares character by character.
Sorting changes the order of your lines and nothing else: the lines themselves are not edited, and equal lines keep their original relative order. One honest limit: sorting does not remove duplicates — a list with the same line twice keeps both copies, in their sorted positions. For a list that needs deduping, use the dedupe tool instead, then sort the cleaned list here.
Frequently asked questions
Why does 10 sort before 2 in alphabetical order?
Alphabetical sorting compares characters, not values, and the character 1 comes before 2. Use the numeric sort order when your lines start with numbers and you want them ordered by value.
Does sorting change my lines in any way?
No. Sorting only changes the order of the lines. The text of each line is left exactly as it was, including any spaces inside it.
What does case-sensitive sorting do?
With case-sensitive sorting on, capital letters sort before lowercase ones, so Banana comes before apple. With it off, which is the default, case is ignored and apple and Apple sort together.
Are equal lines kept in their original order?
Yes. Lines that compare as equal keep the order they had in your input, so a sort is stable and never shuffles identical lines.
Is my list uploaded anywhere?
No. This tool runs entirely in your browser using JavaScript. Your text is never uploaded, stored or sent anywhere — everything stays on this device.
Can I sort lines Z to A?
Yes — pick the Z to A mode and the lines run in reverse alphabetical order, from Z down to A. It works the same way as A to Z, just in the opposite direction.
Can I sort lines by length?
Yes — choose shortest first or longest first. Lines are ordered by how many characters they contain, so the shortest line in the list comes first, or the longest, depending on the mode you pick.
How do I sort numbers in a list?
Use the numeric mode: it treats the lines as numbers, so 2 comes before 10. Alphabetical sorting compares character by character, which is why 10 sorts before 2 — the 1 comes before the 2.