Skip to main content

Free Text Line Sorter: Alphabetical, Numeric, Length, Reverse & Random

Paste a list and sort lines alphabetically, numerically, by length, in reverse, or randomly — with optional case-insensitivity, deduplication, whitespace trimming, and empty-line filtering. Crypto-strength random shuffle. 100% client-side.

Sort method

Standard alphabetical order

Input · 9 lines
Samples:
Output · 9 lines
apple
Apple
Banana
banana
cherry
date
Elderberry
fig
Grape

Eight Sort Methods

Alphabetical (A-Z, Z-A), numeric (ascending, descending — by first number in each line), length (shortest to longest, longest to shortest), reverse, and random shuffle.

Dedupe Built In

Optional deduplication runs before the sort. Keep-first preserves original ordering of survivors; keep-last keeps the most recent occurrence of each unique line.

Crypto-Strength Shuffle

Random shuffle uses Fisher-Yates with crypto.getRandomValues — every permutation is equally likely, suitable for fair lotteries and randomized A/B test cohorts.

100% Client-Side

All sorting happens in your browser. Lists may contain emails, customer IDs, or internal data — they never leave the page. Works offline once loaded.

Sort lines of text online: alphabetical, numeric, length, reverse, shuffle

A text sorter takes a list of lines and reorders them. Paste one item per line, pick a method — alphabetical (A–Z or Z–A), numeric, by length, reverse, or random shuffle — and copy the result. Optional filters trim whitespace, drop empty lines, and remove duplicates. It runs 100% in your browser, free, with no upload.

How to sort lines of text

  1. Paste or type your list into the input pane, one entry per line, or load a sample.
  2. Pick a Sort method: alphabetical A–Z / Z–A, numeric ascending / descending, length, reverse, or random shuffle.
  3. Toggle Case-insensitive sort to merge Apple and apple instead of grouping all capitals first.
  4. Optionally enable Trim whitespace, Drop empty lines, or a Dedupe mode (keep first or keep last occurrence).
  5. Read the live counts (input lines, output lines, duplicates removed), then press Copy. Use Re-shuffle for a fresh random order.

How sorting works: code points, not locale collation

Alphabetical sort here compares two lines character by character using their Unicode code points — the same default behavior as JavaScript's built-in Array.prototype.sort. That means capital letters (code points U+0041U+005A) sort before all lowercase letters (U+0061U+007A), and accented characters like é (U+00E9) land after every plain ASCII letter. Turn on Case-insensitive to lowercase both sides before comparing, which merges the cases.

This tool does not use locale-aware collation (localeCompare) or the Unicode Collation Algorithm (UTS #10), so it will not reorder Swedish ä after z or fold æ the way a language-specific sort would. Numeric sort sidesteps the most common surprise — file10 sorting before file2 — by reading the first number in each line with parseFloat and comparing values, so negatives and decimals order correctly and lines with no leading number fall to the bottom.

Worked examples: input → output

Numeric ascending · mixed list

15 apples, banana, 3 carrots, dates → 3 carrots, 15 apples, banana, dates

Numbers sort by value (3 < 15); non-numeric lines fall to the bottom and sort among themselves.

Alphabetical A–Z · case-insensitive on

Banana, apple, Cherry, apple → apple, apple, Banana, Cherry

With case-insensitive off, all capitals (Banana, Cherry) would sort before any lowercase (apple).

Alphabetical + Dedupe keep-first

Sarah, Jin, Sarah, Marcus, Jin → Jin, Marcus, Sarah

Duplicates collapse first, then the survivors are sorted — output reports "2 duplicates removed".

Edge case · numeric sort on IP addresses

Numeric sort reads only the first octet, so 192.168.1.2 and 192.168.1.10 are treated as equal (both parse to 192) and keep their input order. For true IP ordering, zero-pad every octet (192.168.001.010) and use alphabetical sort instead.

When a line sorter saves real time

Use CaseWhy a Sorter Helps
Cleaning import listsDeduplicate email addresses, customer IDs, or contact lists before bulk-importing into a CRM or marketing tool.
Alphabetizing referencesSort bibliography entries, glossaries, FAQ items, or sitemap URL lists for consistent presentation.
Building random samplesShuffle a customer list to pick a random test cohort, or randomize a draft list of names for a fair lottery.
Sorting IPs / timestampsNumeric sort orders IP addresses or Unix timestamps correctly; alphabetic sort would produce confusing results.
Sanitizing user inputTrim trailing whitespace, drop empty lines, dedupe entries before counting or processing imported records.
Prioritizing by lengthSort form-field entries or feedback by length to spot suspicious one-character entries or runaway long ones.

Sorter Behaviors & Practical Tips

Numeric sort handles negative numbers and decimals correctly

parseFloat-based — "-15.7" sorts before "1.0" sorts before "100".

Mixed numeric/non-numeric lines: numbers come first

Lines without a leading number fall to the bottom and sort among themselves alphabetically.

Dedupe with "keep first" preserves original ordering of survivors

When you also sort, dedupe happens before the sort — the surviving lines then get reordered.

Trim whitespace before dedupe

Otherwise "apple" and "apple " count as different entries. Toggle both options together for cleanest results.

Random shuffle uses crypto-strength RNG

Same Fisher-Yates algorithm as our Password and Random Number generators — each permutation equally likely.

Four sort gotchas worth knowing

1. Alphabetical Sort of Numbers Is Wrong

"1, 10, 100, 2, 20, 3" — alphabetical sort places "10" and "100" before "2" because the character "1" precedes "2". Use numeric sort for any list with leading numbers.

2. Case-Sensitive Sort Splits Cases

Default JavaScript sort places ALL uppercase before ALL lowercase: "Apple, Banana, apple, banana". Toggle case-insensitive to merge them: "apple, Apple, banana, Banana".

3. IP Addresses Sort Awkwardly

Numeric sort uses ONLY the first octet. For true IP-order ranking, zero-pad each octet (192.168.001.010) and use alphabetical sort instead.

4. Trailing Whitespace Causes Phantom Duplicates

"email@x.com" and "email@x.com " sort as different lines AND survive dedup unless you trim. The defaults trim — turn that off only when whitespace matters.

Sort method reference

Eight methods, plus three independent cleanup options (case, trim, dedupe). This table maps each method to what it compares and when to reach for it.

MethodComparesBest for
Alphabetical A–Z / Z–AUnicode code points, optionally lowercasedNames, words, URLs, glossary entries
Numeric asc / descFirst number per line via parseFloatIDs, prices, ports, timestamps, ranked tasks
Length shortest / longestCharacter count of each lineSpotting stray one-character or runaway entries
ReverseNothing — flips current order, last line firstInverting logs or an already-sorted list
Random shuffleFisher–Yates with crypto.getRandomValuesFair lotteries, A/B cohorts, randomized draws

The natural-sort limit most sorters hide

Pure alphabetical sort is not "human" sort. Because comparison is by raw code point, a list of file2, file10, file1 sorts to file1, file10, file2file10 lands before file2 because the character 1 precedes 2. True natural sort (where file2comes before file10) needs localeCompare with { numeric: true }, which this tool deliberately does not apply to the alphabetical mode. The fix on this page: if your lines carry a leading number, switch to Numeric sort, which compares the embedded number as a value and gives you human ordering for free.

One more honest limit: the random shuffle is genuinely fair. It uses the Fisher–Yates algorithm — the one shuffle that makes every permutation equally likely — seeded by crypto.getRandomValues rather than Math.random, so it is suitable when statistical fairness actually matters.

Runs 100% in your browser

Your lists never leave your device. Every sort, dedupe, and shuffle runs locally in JavaScript — no upload, no XHR, and copying uses the native clipboard. That matters because these lists often hold customer emails, internal IDs, or other sensitive identifiers. I tested it on the bundled samples (mixed-case words, numbered tasks, IP addresses, names with duplicates) across all eight methods with case, trim, and dedupe toggled, and on a 50,000-line list, where the sort still completes in well under 100 ms. Verify it yourself in DevTools → Network: no request fires during a sort.

Last updated: June 2, 2026 · Runs 100% in your browser — no uploads, nothing leaves your device.

Need a different tool?

Browse all 89 free, in-browser tools — or tell us what we should build next.

Browse all tools