DevTools Logo

Line Sorter

Line Sorter

Sort lines alphabetically, naturally, numerically or by length, with stable ordering and dedupe.

Runs in your browser
Try an example

Lines to sort

Sorted lines

Paste lines to sort them

Results update as you type. Blank lines and CRLF style are preserved. Nothing leaves your browser.

Details

Sorts text lines with a stable, locale-aware comparator. Alphabetical mode uses English collation with optional case- and accent-insensitivity and numeric-aware digit runs; natural mode uses the same collation with numeric ordering always on; numeric mode compares the first number exactly (labels such as item2 are allowed) and can sink lines without numbers; length mode counts Unicode code points. Equal keys keep their input order in both directions, blank lines and CRLF style are preserved, and dedupe can match normalized lines.

More examples

Alphabetize a dependency list

zod
react
@types/node
lodash
axios

Case-insensitive alphabetical order gives @types/node, axios, lodash, react, zod.

Natural version order

v1.10
v2.0
v1.9
v1.2

Natural mode compares digit runs as numbers: v1.2, v1.9, v1.10, v2.0 instead of v1.10 before v1.9.

Numeric lines

10
9
2
1

Numeric mode sorts 1, 2, 9, 10 rather than the lexical 1, 10, 2, 9.

Invalid numeric input

10
latest
3
release
2

Numeric mode reports line 2 because it has no digit; sink non-numeric lines keeps those lines at the end instead.

    Examples

    Natural version tags

    Input
    v1.10
    v2.0
    v1.9
    v1.2
    Output
    v1.2
    v1.9
    v1.10
    v2.0

    Natural mode compares digit runs as numbers, so 9 comes before 10.

    Case-insensitive dedupe

    Input
    Apple
    apple
    APPEL
    banana
    Output
    APPEL
    Apple
    banana

    With Ignore case on, Apple and apple share a dedupe key; the first occurrence is kept.

    Numeric mode with a label

    Input
    item10
    item2
    item1
    Output
    item1
    item2
    item10

    Numeric mode reads the first number in each line and falls back to the full line when numbers tie.

    Use cases

    Tidy a dependency list

    Paste imports or package names, ignore case, and copy an alphabetized list for a README or lockfile review.

    Order version tags

    Use Natural mode so v1.9 sorts before v1.10 instead of the lexical order a plain A–Z sort gives.

    Sort numbered log lines

    Use Numeric mode for counters and IDs, and turn on Sink non-numeric lines to keep header rows at the end.

    Clean a pasted list

    Trim whitespace, remove blank lines and dedupe in the same pass, with warnings showing what changed.

    Common mistakes

    Mistake:Using alphabetical order for version numbers, which puts 10 before 9.

    Fix:Choose Natural (human) mode, or turn on Numeric-aware in Alphabetical mode.

    Mistake:Expecting descending order to reverse tied lines.

    Fix:This tool inverts the comparison instead: equal keys keep their original order in both directions.

    Mistake:Turning on Unique lines and assuming lines that differ only in case are different.

    Fix:Turn on Ignore case (or Ignore accents) to normalize dedupe keys; the tool warns when normalized duplicates are removed.

    Frequently asked questions

    Why does 10 come before 9 when I sort lines?

    Alphabetical collation compares characters, so the 1 in 10 sorts before 9. Choose Natural (human) mode, or turn on Numeric-aware in Alphabetical mode, and digit runs are compared as numbers: 2, 9, 10 and v1.9 before v1.10. Mode and option changes re-sort the input immediately.

    What happens to lines without numbers in Numeric mode?

    Numeric mode reads the first number in each line, so labels such as item2 work. A line with no digit produces an error that names the line and shows its text. If you want to keep mixed content, turn on Sink non-numeric lines: those lines stay at the end in their original order, even in descending mode. Equal numbers fall back to the full line text.

    Does the sort ignore case, accents or both?

    Neither is ignored by default. Ignore case uses collation that treats A and a as equal while still distinguishing accents; Ignore accents keeps case significant but treats é and e alike; enabling both compares only base letters. The same normalization is used for dedupe keys, so removing a line that matched only after normalization is reported in a warning.

    Are blank lines and CRLF line endings preserved?

    Yes. Interior blank lines stay in the output and are counted in the stats, and a trailing newline does not create a phantom empty line. Remove blank lines drops them and reports how many were removed. CRLF input stays CRLF; if an input mixes CRLF and LF, everything is normalized to the first line-ending style and a warning explains the change.

    Is my text uploaded anywhere, and is there a size limit?

    Nothing leaves your browser. Sorting, dedupe and statistics all run locally in pure JavaScript, and no text is stored on a server; saved input stays in your browser's local storage until you clear it. Input is capped at 5 MB, and the output textarea previews the first 1,000 lines so huge pastes stay responsive. Copy and download always use the complete result.

    References & standards