Sort Lines

ToolText · updated 5 October 2026

banana apple Cherry apple 10 items 9 items

Lines: 7

The fields work with JavaScript on. Above is a worked example.

Paste a list into the “Text” field, one item per line, and pick an action: the “Result” field updates as you type. Copy it with the button below, or send it back into the field with “Back into the field” to apply another action on top, for example remove duplicates and then sort.

Sorting

“A → Z” and “Z → A” sort by the alphabet of the page language, ignoring case: “banana”, “Cherry” and “apple” come out as apple, banana, Cherry. Numbers inside a line are compared as whole numbers, so “9 items” comes before “10 items”. “By length” puts the shortest lines first. “Reverse order” turns the list upside down without sorting it.

Duplicates and empty lines

“Remove duplicates” keeps the first occurrence of each line and drops the rest; the line under the result says how many were removed. By default “Apple”, “apple” and “ apple “ count as the same line; the switch under the action list turns that off. “Remove empty lines” drops lines that are empty or contain only spaces, and “Trim spaces” removes spaces at the start and end of every line.

Numbering

“Number lines” adds “1. “, “2. “ and so on to every line. “Remove numbering” takes off a leading number with a dot or a bracket (“1.” or “1)”) or a list marker such as “-”, “•”, “*” or “—” — in both cases only when a space follows it.

Split, join, add to each line

“Split into lines” turns “red, green, blue” into a column, one item per line; “Join into one line” does the opposite. Both use the separator in the field under the action list, by default a comma and a space. For a tab or a line break, type \t or \n in the field: a tab-separated row splits into a column, and a column joins into a tab-separated row. “Add to each line” puts the same text at the start or end of every line — for example quotes and a comma to turn a column into a list for code.

Questions

Why does "9 items" come before "10 items"?
Numbers inside a line are compared as numbers, not digit by digit. Compared character by character, "10" would come first because 1 is less than 9; here 9 is less than 10, so the order is the one a person expects.
Are "Apple" and "apple " duplicates?
With the switch "Ignore case and edge spaces when removing duplicates" on, yes: the lines are compared in lower case with spaces at the ends trimmed. Turn it off to keep lines that differ in case or spacing. The first occurrence always stays, later copies are removed.
Is the shuffle random?
The first shuffle after the page opens is always the same. "Shuffle again" draws a new random order from your browser's random number generator.
Is my text sent anywhere?
No. Lines are processed in your browser; the text is not sent to a server and not saved.