Sort Text Lines Online

Sort any list alphabetically, by line length, by the number in each line, or simply flip the order — with natural sorting, so item2 comes before item10.

Runs in your browser. Your image is never uploaded.

How to use Sort Text Lines Online — A to Z, Length, Numeric

  1. 1Paste your list or text into the left-hand box.
  2. 2Choose how to sort — alphabetically, by length or numerically.
  3. 3Copy the result, or download it as a text file.

About Sort Text Lines

Sorting a list is the kind of thing a spreadsheet does badly when the list is just text. Paste a column into a spreadsheet and you get type coercion, autocorrect, leading zeros disappearing and dates invented out of anything that looks remotely like one. Pasting the same lines here changes nothing about the text — the lines are reordered and handed straight back, so codes, IDs and anything starting with a zero survive intact.

Natural sorting is the detail worth knowing about. A conventional sort compares character by character and therefore places item10 between item1 and item2, which looks wrong to every human who reads it. This tool compares digit runs as numbers, so a list of chapters, versions, filenames or numbered tickets comes out in the order you expect. Alphabetical comparison also follows your browser's locale rules, which keeps accented letters near their unaccented counterparts rather than exiling them to the end of the list.

The other orders each solve a specific problem. Sorting by length, longest first, immediately surfaces the lines that will overflow a fixed-width field or a character limit. Numeric sorting works on lines that mix text and figures, taking the first number it finds — useful for "12 units", less useful for formatted currency, where a thousands comma cuts the number short and gives a wrong order. Reverse simply flips the list you already have, which is the quickest way to turn an oldest-first export into a newest-first one.

Blank lines are dropped unless you ask to keep them, and "Trim spaces around each line" removes leading and trailing whitespace before comparing, so an accidentally indented line does not sort somewhere strange. As with every tool on this page, the sorting happens in your own browser: the list never reaches a server, so it is safe to use on data you would not paste into an online form.

Frequently asked questions

What is natural sorting, and why does it matter?
Plain alphabetical sorting compares one character at a time, so it puts item10 before item2 because the character "1" comes before "2". Natural sorting reads a run of digits as a number, giving item1, item2, item10, item20. This tool sorts naturally by default, which is what you almost always want for filenames, versions and numbered items.
Is A to Z case-sensitive?
It uses your browser's locale comparison, which groups "apple" next to "Apple" rather than pushing every capital letter to the top the way a raw byte sort does. Tick "Ignore upper / lower case" to make capitalisation count for nothing at all in the comparison.
How does numeric sorting handle text around the number?
It takes the first number it finds in each line and sorts on that, so "30 apples" and "apples 30" both sort as 30, and negative numbers work correctly. Two real limitations: a line with no digits counts as zero and lands at the start, and thousands separators break it — "$1,200" is read as 1, so it sorts before "$900". Strip the commas before sorting money.
What does "reverse the current order" do?
It flips your list bottom-to-top without sorting it, which is what you want for a log you need newest-first. It is not the same as Z to A: if you want reverse alphabetical, choose "Z to A" directly rather than sorting A to Z and then reversing.
Does sorting remove duplicates?
No — every line you paste comes back. Sorting does make duplicates obvious, because identical lines end up adjacent, so it pairs well with the duplicate remover when you want them gone as well as visible.
How is line length measured?
In characters, including spaces and punctuation. Be aware that emoji and some accented characters are stored as more than one unit and so count as more than one character — fine for spotting your longest lines, but do not treat the length sort as a strict character-limit check for titles or meta descriptions.