ToolHarbor

Text Sorter Online

Sort lines of text alphabetically, by length, or randomly. Free online tool with case-sensitive and trim options.

Features

  • Sort lines alphabetically A–Z or Z–A
  • Sort by line length (shortest or longest first)
  • Random shuffle for quick randomization
  • Case-sensitive or case-insensitive sorting
  • Trim whitespace and remove empty lines
  • Instant results as you type

How to Use

  1. 1Paste your text into the input area (one item per line)
  2. 2Choose a sort mode: alphabetical, by length, or random
  3. 3Toggle case-sensitive, trim, or ignore empty lines as needed
  4. 4The sorted result appears instantly in the output panel
  5. 5Click Copy to copy the sorted text to your clipboard

Examples

Alphabetical sort (A–Z)

Input

cherry
apple
banana
date

Output

apple
banana
cherry
date
Reverse alphabetical (Z–A)

Input

cherry
apple
banana
date

Output

date
cherry
banana
apple
Sort by length (shortest first)

Input

strawberry
fig
apple
kiwi

Output

fig
kiwi
apple
strawberry
Case-insensitive sort

Input

Banana
apple
Cherry
date

Output

apple
Banana
Cherry
date

How to Sort Text Lines Online

Sorting lines of text is one of the most common operations when working with lists, data exports, log files, or any plain-text content. This tool takes your input, splits it into individual lines, and reorders them based on the sort mode you choose — all in your browser with zero server calls.

Alphabetical sorting (A–Z or Z–A) uses locale-aware comparison, so accented characters and international text sort correctly. When case-sensitive mode is off, "Apple" and "apple" are treated as equal for ordering purposes, which is useful for messy data where capitalization is inconsistent.

Length-based sorting is handy when you need to find the shortest or longest entries in a list — for example, sorting CSS class names, variable names, or dictionary words. When two lines have the same length, they fall back to alphabetical order for a stable, predictable result.

Random shuffle uses the Fisher–Yates algorithm to produce an unbiased random permutation. This is useful for randomizing quiz answers, playlist orders, raffle entries, or any list where you need a fair shuffle.

The trim whitespace option strips leading and trailing spaces from each line before sorting, preventing invisible characters from affecting the order. The ignore empty lines option removes blank lines from the result, keeping your output clean and compact.

Frequently Asked Questions

Related Tools