Skip to content
CleanGlyph home

Sort Lines Online

Sort text lines alphabetically, numerically, by length or in reverse order. Organize lists instantly while preserving the original text of each line.

Your text never leaves your browser.

0 lines · 0 non-empty · 0 charactersAnalyzed as you type

Sorted text

Paste text to sort your lines.

Sorting options

Sort orderSort order
Matching

Sort file2 before file10 instead of comparing the digits as ordinary text.

Compare uppercase and lowercase letters as equivalent. Original capitalization is preserved.

Compare lines without their outer whitespace. The output keeps the original spaces and tabs. Numeric sorting always ignores outer whitespace.

Duplicates

Keep the first exact copy of each line before sorting.

Need more duplicate matching options? Use Remove Duplicate Lines.

Blank lines
Blank lines

Blank and whitespace-only lines are kept and placed after the sorted lines, in their original order.

How to sort lines alphabetically

Paste a list into the input box, pick A → Z or Z → A and copy the sorted text. The result updates while you type. Comparison uses fixed English collation, so the order is the same in every browser, and capital letters sort together with lowercase ones unless you turn off Ignore case. Lines that compare as equal keep the order they had in your input.

Natural sorting vs alphabetical sorting

Plain alphabetical sorting compares text one character at a time. Because the character 1 comes before 2, file10 lands before file2. Natural sorting reads each run of digits as a whole number, which is how people expect numbered files, chapters and versions to be ordered.

Alphabetical (natural sorting off)
file1
file10
file2
Natural sorting (default)
file1
file2
file10

Sort numbers from smallest to largest

Numeric ↑ and Numeric ↓ treat each line as a decimal number. Negative numbers, decimals, leading zeros and plus signs work, so -5, 2.5, 3, 20 and 100 sort as you would expect. Numbers are compared digit by digit instead of being converted to floating point, so values larger than 9007199254740991 still sort correctly. A line only counts as a number when the whole line is one: 12px, $50, 1,200 and scientific notation such as 1e3 are not. Those lines are never discarded; they are kept at the end in their original order.

Sort lines by length

Shortest and Longest count visible characters, called graphemes, rather than code units. The technologist emoji 👩‍💻 is built from three code points (woman, zero width joiner, laptop) and five UTF-16 code units, but it displays as one character and counts as one. An e followed by a combining accent also counts as one. Lines with the same length keep their original order.

Keep blank lines and text formatting

Sorting moves whole lines. Spaces, tabs, capitalization and punctuation inside each line are written exactly as they were. Line breaks in the result are written as LF, whether your input used LF, CRLF or CR, and a final line break at the end of your input is kept. Choose how blank lines are handled:

  • Move to end

    The default. Blank and whitespace-only lines are kept and placed after the sorted lines.

  • Keep sections

    Blank lines separate groups. Each group is sorted on its own and the blank lines stay put.

  • Remove

    Blank and whitespace-only lines are deleted. Spaces inside other lines are untouched.

Keep sections is useful for grouped lists, such as several categories separated by blank lines, where each group should be alphabetized without mixing them. In Reverse mode the full sequence, blank lines included, is simply flipped.

Unicode-aware sorting

Accented letters sort next to their base letter, so München sorts among the M words rather than after Z. With Ignore case on, Apple and apple compare as equal but é is still different from e. Text is never normalized: a precomposed é and an e with a combining accent may sort together, but each line keeps its own encoding. Invisible characters such as zero width spaces, joiners, non-breaking spaces and bidirectional marks are never removed, even when they change where a line sorts. To see what a line actually contains, use the Unicode Inspector or the Invisible Character Detector. To strip unwanted spacing first, use the Text Cleaner.

Sort Lines vs Remove Duplicate Lines

Sort Lines changes the order of lines. The optional Remove exact duplicate lines checkbox is a convenience that only drops lines that are character-for-character identical, keeping the first copy. When you need to match duplicates regardless of case or whitespace, or keep the last copy, use Remove Duplicate Lines, which keeps your original order. To check what changed between two versions of a list, paste both into the Text Difference Checker.

Frequently asked questions

How do I sort lines alphabetically online?

Paste your text into the input box and choose A → Z or Z → A. The sorted result updates as you type, so you can copy it straight away. No button press or upload is needed.

Can I sort numbers from smallest to largest?

Yes. Choose Numeric ↑ for smallest first or Numeric ↓ for largest first. Positive and negative integers and decimals such as -5, 2.5, .75 and +7 are supported, and very large numbers are compared exactly. Lines that are not plain numbers, such as 12px, $50, 1,200 or 1e3, are kept at the end in their original order.

What is natural sorting?

Natural sorting compares runs of digits inside text as numbers, so file2 comes before file10. Ordinary alphabetical sorting compares digits one character at a time and would put file10 before file2. Natural sorting is on by default and can be turned off.

Does sorting remove duplicate lines?

Not by default. Every line is kept, including repeats. You can turn on Remove exact duplicate lines to keep only the first identical copy of each line, or use Remove Duplicate Lines for case-insensitive and whitespace-insensitive matching.

Can I sort lines without changing their text?

Yes. The tool moves whole lines and keeps their contents exactly, including spaces, tabs, capitalization and invisible characters. Output line breaks are written as LF, and lines are only removed when you turn on duplicate removal or choose Remove for blank lines.

Can I ignore uppercase and lowercase letters?

Yes. Ignore case when sorting is on by default, so apple, Apple and APPLE sort together and keep their original order. The capitalization of each line is never changed. Accents still count, so e and é are not treated as the same letter.

Can I keep blank lines between sections?

Yes. Set Blank lines to Keep sections. Each block of lines between blank lines is sorted on its own and the blank lines stay where they were. Move to end puts all blank lines after the sorted lines, and Remove deletes them.

Can I sort lines by length?

Yes. Shortest and Longest sort by the number of visible characters. Emoji and accented letters made of several Unicode code points count as one character each. Lines of equal length keep their original order.

Does it support accented characters and emojis?

Yes. Sorting uses Unicode-aware English collation, so accented letters sort next to their base letters, and lengths are measured in graphemes. Unicode characters are never removed or normalized.

Is my text uploaded to a server?

No. Sorting runs entirely in your browser. Your text is not sent to a server, stored, put in the address bar or included in analytics.