Sort Lines Alphabetically

Alphabetize or numerically order any list — names, imports, CSV values, to-do items — instantly. Natural sort keeps item2 before item10. Everything runs in your browser.

Sort:

How to sort lines

  1. Paste your list into the top box, one entry per line: names, import statements, CSV values, to-do items or keywords.
  2. Pick a mode (A→Z, Z→A, numeric ascending, numeric descending or by length) and set the options. Case-insensitive, Trim lines and Ignore blank lines are on by default; Remove duplicates too is off.
  3. The sorted list appears below as you type. Click Copy or Download .txt (saved as sorted-lines.txt).

Worked example

Take these six lines: banana, Apple, cherry, apple, item10, item2. With A→Z and Remove duplicates ticked, the output is Apple, banana, cherry, item2, item10. The lowercase apple is removed because case-insensitive matching treats it as a duplicate, and the copy that appeared first in your input (Apple) is the one kept. Duplicates are removed before sorting, so the order of survivors never depends on which copy was dropped.

Natural sorting: item2 comes before item10

A plain character-by-character sort puts item10 before item2, because “1” is smaller than “2”. This sorter uses the browser’s locale-aware comparison with numeric mode on, so digit runs inside text are compared as whole numbers. File names, version labels such as v1.9 and v1.10, and numbered chapters come out in the order a person expects.

What each option really does

  • Case-insensitive treats Apple and apple as equal but still tells accented letters apart, so é is not merged with e. Lines that compare as equal keep their original relative order. Turn it off and lines that differ only by case are considered different; in most browsers lowercase then sorts just ahead of its uppercase twin, rather than all capitals jumping to the top.
  • Trim lines removes leading and trailing whitespace from every line, which also changes what counts as a duplicate: apple and apple  (with a trailing space) match only when trimming is on.
  • Ignore blank lines drops empty lines from the result. Untick it and blank lines are kept and sort to the top in ascending order.
  • Numeric modes read the number at the start of each line with parseFloat. 12 apples sorts as 12 and -3 as −3. A line like $5 or Item 4 has no leading number, so any comparison involving it falls back to text order. Keep number-free lines out of a numeric sort if you want a clean result.
  • By length counts characters and breaks ties alphabetically. Emoji and some rare characters count as two, so lengths can differ slightly from what you see.

Practical uses

Developers sort import lists or environment variables so diffs stay small. SEO and marketing teams alphabetize keyword lists before deduplicating them. Writers order glossaries, reference lists and character names. Spreadsheet users sort a single pasted column without opening Excel. Line endings are normalised, so Windows, Mac and Unix text all sort the same way, and the output always uses plain line breaks.

Is my text private?

Yes. Sorting runs in your browser with JavaScript, so your list never leaves your device. There is no account and no upload.

Related guides

If you only need to strip repeats without reordering, use Remove Duplicate Lines. To compare a list before and after sorting, try Text Diff, or read how to compare two texts. For long lists, the word counter shows how much text you are handling.

Frequently asked questions

Does it do natural numeric sorting?

Yes. The alphabetical modes compare digit runs as whole numbers, so item2 comes before item10 instead of after it. The same applies to file names and version labels such as v1.9 and v1.10.

Can it sort case-insensitively?

Yes, and it is on by default, so Apple and apple are treated as equal. Accented letters are still distinguished. With the option off, lines that differ only by case count as different, and lowercase typically sorts just before uppercase.

How does numeric sorting treat lines without numbers?

Numeric modes read the number at the start of each line using parseFloat. If either line in a comparison has no leading number, the tool falls back to normal text order for that pair. For best results, keep a numeric sort to lines that all begin with a number.

Can it remove duplicates while sorting?

Yes. Tick Remove duplicates too and identical lines collapse to one. Matching follows your case option and happens after trimming, and the first copy in your input is the one that is kept.

What happens to blank lines?

By default they are dropped. If you untick Ignore blank lines they stay in the output and, in an A to Z sort, move to the top.

Does it change my line endings?

Windows, Mac and Unix line breaks are all recognised on input. The output is joined with standard line breaks.

Is my text uploaded to a server?

No. Sorting happens entirely in your browser, so your list never leaves your device.

Is there a size limit?

There is no fixed limit in the tool. Very large lists are limited only by your browser memory, and typical lists of thousands of lines sort instantly.