Sort lines of text

Paste a list and sort it alphabetically, numerically, by line length or in natural order, where item2 comes before item10. Duplicates can be dropped in the same pass, comparison can ignore case, and sorting respects your locale so accented letters sit beside their base letter instead of after Z.

✓ Runs in your browser — nothing uploaded Free, no sign-upNo watermark

How to use the Sort Lines

  1. Paste your list, one item per line.
  2. Choose the order — natural is usually what you want for anything with numbers in it.
  3. Tick "remove duplicates" to deduplicate in the same pass.
  4. Copy the sorted list or download it as a text file.

Alphabetical, natural and numeric

These three are easy to confuse and give very different answers.

InputA–ZNaturalNumeric
item10, item2, item1item1, item10, item2item1, item2, item10item1, item2, item10
9, 100, 20100, 20, 99, 20, 1009, 20, 100
v1.9, v1.10v1.10, v1.9v1.9, v1.10v1.9, v1.10

A–Z compares character by character, so 10 sorts before 9 because "1" precedes "9". Natural order treats runs of digits as numbers inside otherwise textual lines — it is what a file manager uses, and the right choice for filenames, version strings and anything like Chapter 2. Numeric extracts the first number from each line and sorts on that alone, which suits a column of figures, prices or scores; lines with no number are pushed to the end and the count is reported.

Locale-aware comparison

Sorting uses your browser's collator rather than raw code-point order. In practice that means é sorts next to e instead of after z, and Ä behaves the way a reader of your language expects. Raw code-point sorting puts every capital letter before every lowercase one, so Zebra would come before apple; the collator does not, which is almost always what you want. Tick "ignore letter case" to make the comparison case-blind entirely.

Sorting by length

Shortest-first and longest-first are more useful than they sound: they surface the outliers in a list of product titles, find the one URL that is far longer than the rest, or order a set of CSS selectors by specificity of expression. Lines of equal length fall back to alphabetical order so the result is stable.

Whitespace and blank lines

Leading and trailing spaces are trimmed before comparison by default, because an indented line would otherwise sort to the top of the list regardless of its content. Blank lines are dropped by default for the same reason. Turn both off if you are sorting a block of code or anything where indentation carries meaning.

Deduplicating while sorting

Ticking "remove duplicates" keeps the first occurrence of each line before sorting, and the summary tells you how many were dropped. If you need to remove duplicates without reordering, use the dedicated remove-duplicate-lines tool instead.

Frequently asked questions

What is natural order?

Digit runs inside text are compared as numbers, so item2 comes before item10 and v1.9 before v1.10. It is the ordering file managers use.

Why does A–Z put uppercase and lowercase together?

Comparison uses your locale collator rather than raw character codes, so Apple and apple sort next to each other and accented letters stay beside their base letter.

How are lines without numbers handled in numeric sort?

They are moved to the end of the list and counted in the summary, so nothing disappears.

Can I sort and deduplicate at once?

Yes. Tick "remove duplicates"; the first occurrence of each line is kept before sorting.

Privacy

This tool runs entirely inside your browser using WebAssembly and the Canvas/File APIs. Your files are never uploaded to ToolFlint or any third party; you can verify this in your browser's network tab or by switching to airplane mode after the page loads. Read how we process files.

Last updated 2026-09-23.