Skip to content
epitometool

Sort lines

Text utilities

Sort lines alphabetically, naturally or numerically; dedupe, trim and reverse in one click.

Updated

Input

One line per item. CRLF and LF both work. A trailing newline is normalised.

Sort mode

Output

  • EnterCopy output
  • KClear input

Quick start

How to sort a list of lines

Paste lines, pick a sort mode, copy the result.

  1. Step 1
    Paste your lines

    One item per line. CRLF and LF endings are both fine; the tool normalises them.

  2. Step 2
    Choose a sort mode

    Alphabetical, natural, numeric, by length, or shuffle. Tick descending or any pre-processing options you need.

  3. Step 3
    Copy the result

    Hit Copy or ⌘/Ctrl+Enter. Use 'Send to input' to chain another operation.

In-depth guide

Sort lines: alphabetical, natural, numeric, dedupe and more

Paste a list, pick a sort mode, get a clean ordered list back. Optional pre-processing steps — trim whitespace, drop blank lines, remove duplicates — run before the sort so the result is exactly what you want. Everything happens locally in your browser.

The six sort modes

ModeComparatorBest for
AlphabeticalString.localeCompareNames, words, identifiers — the everyday default.
Alpha, ignore caseLowercased localeCompareWhen Banana and banana should group together.
NaturalIntl.Collator with numeric: trueFile names, version numbers, IP addresses (where digits matter).
NumericNumber() then a − bPure numeric lists (counts, prices). Non-numbers fall to the end.
By lengtha.length − b.lengthSpotting the shortest or longest string in a list.
ShuffleFisher–Yates (Math.random)Random reorder for fair sampling or test fixtures.

Pre-processing options

The pre-processing checkboxes run before sorting, in this order:

  1. Trim each line — strip leading and trailing whitespace from every line. Useful when the source has inconsistent indentation.
  2. Drop blank lines — remove empty lines (after trimming, if enabled). Keeps the output compact.
  3. Remove duplicates — keep only the first occurrence of each line. Order at this stage is still the original order; the sort happens after.

If you toggle Reverse instead of sorting, the comparator step is skipped — the pre-processed list is just flipped end-to-end. Pair it with "Remove duplicates" to dedupe while preserving original ordering.

Why natural sort matters

Lexicographic comparison treats every character as a code point, so digits sort by their Unicode value rather than their numeric meaning. That puts file10.txt before file2.txt because 1 (U+0031) is less than 2 (U+0032).

Natural sort uses Intl.Collator(undefined, { numeric: true }), which is the browser-native implementation of the same algorithm Finder, Explorer and most modern file managers use. It detects digit runs and compares them as numbers, giving you the order humans expect:

file2.txt
file10.txt
img-3.png
img-12.png
img-100.png

Tips and pitfalls

  • Locale sensitivity — alphabetical and natural sort use the browser's default locale, so accented characters (é, ñ, ü) sort the way that locale expects. If you need deterministic byte ordering instead, run the sort in Node with an explicit locale.
  • Mixed numeric input — numeric mode is strict: "12" sorts as 12, but "12 apples" sorts as a non-number and falls to the end. Use natural sort for mixed alphanumeric input.
  • Trailing newlines — a single trailing newline is normalised so the output doesn't grow an extra blank line on every round-trip. Multiple trailing blanks are preserved unless you tick "Drop blank lines".
  • Send to input — chain multiple operations (e.g. sort first, then dedupe) by clicking "Send to input" between runs.

When to use it vs alternatives

Use this tool for quick text transformation, inspection, decoding, testing, or generation without opening a heavier application. Use a project script or test suite when the same transformation must be repeated automatically.

Frequently asked questions

Does this tool send my lines anywhere?

No. Sorting happens entirely in your browser's JavaScript engine. DevTools → Network will show zero requests while you paste and sort.

What does 'Natural' sorting do?

Natural sort uses Intl.Collator with `numeric: true`, so it sorts `file2.txt` before `file10.txt` instead of the lexicographic `file10.txt` before `file2.txt`. macOS Finder, Windows Explorer and most file managers behave the same way.

What's the difference between alphabetical and 'ignore case'?

Plain alphabetical respects the locale's default case order (often uppercase before lowercase, so `Banana` < `apple`). 'Ignore case' lowercases both values before comparing, so `Banana` and `banana` are treated as equal and grouped together.

How does numeric mode handle non-numbers?

Non-numeric values are pushed to the end of the list, sorted alphabetically among themselves. So `12`, `2`, `apple`, `100`, `banana` becomes `2`, `12`, `100`, `apple`, `banana`.

Does 'Remove duplicates' care about case or whitespace?

By default it's an exact-match comparison. Combine it with 'Trim each line' to ignore leading/trailing whitespace, or sort with 'Alpha, ignore case' first to spot case-variant duplicates manually.

Why does 'Reverse instead of sorting' disable the other sort options?

Reverse is a different operation — it keeps the original order and flips it, regardless of the chosen sort mode. Pre-processing (trim, drop blanks, dedupe) still applies; only the sort itself is replaced.

Is the shuffle cryptographically random?

No. It uses a Fisher–Yates shuffle backed by Math.random, which is fine for picking a winner or jumbling test data, but not for anything security-sensitive (lottery, cryptographic salts, etc.).

What's the line-count limit?

No hard cap — JavaScript can sort millions of strings in a fraction of a second. The textarea itself is the constraint: very large pastes (tens of MB) might slow rendering. Paste in chunks if you hit that.

Keep exploring

More tools you'll like

Hand-picked utilities that pair well with the one you're on — all free, client-side, and zero-signup.