Skip to content
ToolPlankDEV
Text Tools
100% In-Browser Execution

Updated:

Sort Lines Alphabetically

Paste a list and sort lines in one step. Sort A to Z or Z to A in natural order, by number or by length, reverse the order or shuffle it. Blank lines and duplicates can be removed while you sort. Nothing is uploaded.

Options:

Your list

Input
0 chars · 0 lines

Sorted list

Ready
Processing in browser...
0 chars · 0 linesUpdates as you type

Processed on your device. Your text is not sent to our servers.

More free tools you may need next.

Quick Guide

How to use Sort Lines

Simple step-by-step instructions to get the exact output you need.

  1. 01

    Paste your lines

    Paste the list into the Your list box, one item per line, or press Paste, or drop a .txt file onto the box. Press Example to load a short list with mixed capitals and numbers.

  2. 02

    Choose how to sort

    Sort offers A to Z, Z to A, by number, by length, reverse and random order. The sorted list appears at once and updates as you change the list or the options.

  3. 03

    Adjust the details

    Natural order, Match case and Ignore leading spaces decide how lines are compared. Remove empty lines and Remove duplicates clean the list at the same time.

  4. 04

    Copy the result

    Press Copy to put the sorted list on your clipboard, or Download to save it as a text file.

How to Sort Lines Alphabetically

To sort lines alphabetically, paste them into the box. The tool puts the lines in A to Z order and shows the result on the right. This is the Example list with the default settings:

Text
Apple
apple
banana
fig
item1
item2
item10
pear

Apple and apple are treated as equal when sorting, so they stay in the order they had in your list. Numbers inside a line are read as numbers, which is why item2 comes before item10. Switch to Z to A to reverse the alphabetical order.

Natural Order: item2 Before item10

A plain alphabetical sort compares character by character, so item10 comes before item2, because 1 is smaller than 2. That is rarely what you want for file names, versions and numbered lists. Natural order is on by default and compares the digits as whole numbers. Turn it off to get the strict character order:

Text
Natural order on:  item1, item2, item10
Natural order off: item1, item10, item2

Capital Letters, Accents and Leading Spaces

  • Match case off: Apple, apple and APPLE count as equal. Equal lines keep the order they had before.
  • Match case on: capitals count, and for the same letter the lowercase line is put first, so apple comes before Apple.
  • Accents: letters such as é sort next to e, not after z. The exact order of accented and non-Latin letters follows your browser's rules for text, so it can differ between languages and browsers.
  • Ignore leading spaces: compares the lines as if the spaces at the start were not there. The lines are not changed, so an indented line stays indented.

Sort by Number, by Length, Reverse or Shuffle

Sort by number looks at the first number in each line and orders the lines by its value, so 9 comes before 12 and 100. Negative numbers and decimals with a point work. Commas inside numbers do not. A line without any number is placed after the numbered lines, in its original order. With this list:

Text
Invoice 12 paid
Invoice 9 open
Invoice 100 open
Notes

→  Invoice 9 open
    Invoice 12 paid
    Invoice 100 open
    Notes
  • By length: orders lines by the number of characters, short first or long first. Lines of the same length keep their order.
  • Reverse the order: turns the list upside down without sorting it.
  • Random order: shuffles the list. The order is different every time you change the list or an option, because it is random by design. To pick a few random lines or repeat an order with a seed, use Shuffle Lines.

Remove Empty Lines and Duplicates While You Sort

Remove empty lines is on by default, because blank lines would be collected at the top of an A to Z list. Turn it off to keep them. Remove duplicates keeps the first copy of each line before the sort, and it follows the Match case setting. With Example and Remove duplicates on, apple is dropped because Apple came first.

For more control over duplicates, Remove Duplicate Lines can also trim spaces and show only the repeated lines. A sorted list can be turned into one line with Column to Comma Separated List.

Sorting Lines in Other Programs

Many text editors have a sort lines command, and word processors can sort paragraphs. Where yours does not, paste the lines here, sort them and paste the result back. On the command line, sort file.txt sorts a file alphabetically, sort -n file.txt sorts by number and sort -u file.txt sorts and removes duplicates.

To change the capital letters of a spreadsheet column first, the Excel Case Converter works on whole files. To see how often each word of a text occurs, use the Word Frequency Counter.

Limits and Privacy

  • The tool sorts whole lines. It cannot sort by a column or a field inside a line.
  • Sort by number uses only the first number in each line.
  • Input is limited to 2,000,000 characters.

Your list is sorted by code running in your browser. It is not sent to a server and not stored. See the Privacy Policy for details.

Frequently Asked Questions

Technical Q&A for Sort Lines

Common questions about edge cases, character encoding, and privacy guarantees.

Paste the lines into the box and leave Sort on A to Z. The sorted list appears on the right. Choose Z to A for the reverse order.

Yes, this is one. Paste the names one per line and the list is put in alphabetical order. Turn on Remove duplicates if a name appears twice.

Leave Natural order on. Numbers inside the lines are compared as numbers, so item2 comes before item10.

Yes. Set Sort to By number, low to high or high to low. Lines are ordered by the first number in each line.

Yes. Choose By length, short first or By length, long first. Lines of the same length keep their order.

By default, yes. Apple and apple are treated as equal. Turn on Match case to put lowercase before uppercase for the same letter.

Turn on Remove duplicates. The first copy of each line is kept and the list is then sorted.

Yes. Choose Random order. The list is shuffled again each time you change the text or an option.

Remove empty lines is on by default. Turn it off to keep blank lines, which are placed at the start of an A to Z list.

No. The list is sorted in your browser and nothing is sent to a server or saved. Reloading the page clears it.