Sort Text Lines
Sort lines alphabetically, numerically, or in natural order, and remove blank or duplicate lines.
Paste names, numbers, keywords, URLs, IDs, spreadsheet rows, or any one-item-per-line list. Need to sort dates or CSV rows by a column? Use the Data Sorter.
Natural sort keeps item2 before item10. Numeric sort is different from alphabetical sort.
Sorted output preview
7 42 100 apple Apple Banana banana item1 item2 item10 Name orange pear
Input lines
14
Total lines before cleanup.
Output lines
13
Lines after sorting and cleanup.
Sort mode
Natural sort
Selected comparison method.
Blank lines removed
1
Removed only when enabled.
Duplicates removed
0
Removed only when enabled.
Header preserved
No
First line fixed at the top.
Case-sensitive
Off
Controls text comparison.
Numeric warnings
0
Invalid numeric lines.
Local sorting
Lines are sorted in your browser and are not uploaded. No account is needed.
Cleanup controls
Trim lines, remove blanks, remove duplicates, and preserve headers.
Copy-ready output
Copy or download sorted plain text for spreadsheets, forms, or editors.
How Text Line Sorting Works
- 1. The input is split into lines. Windows (CRLF), Unix (LF) and old Mac (CR) line breaks are all recognized.
- 2. If trimming is on, leading and trailing spaces are removed from every line, including the first.
- 3. If header mode is on, the first line is set aside. It is never sorted and is not affected by blank-line or duplicate removal.
- 4. If removing empty lines is on, blank and whitespace-only lines are dropped.
- 5. If removing duplicates is on, only the first copy of each repeated line is kept.
- 6. The remaining lines are sorted using the selected mode.
- 7. The header, if any, is put back on top and the lines are joined with the selected line ending.
Alphabetical, Numeric, Natural, and Length Sorting Explained
Alphabetical
Compares lines as text, so item10 comes before item2.
Numeric
Compares number values, including decimals and negatives. Commas are accepted only as thousands separators (1,234 or 12,345.67); lines such as 1,5 or 1,2,3 are flagged as non-numeric and placed at the end.
Natural
Compares runs of digits as numbers, so item2 comes before item10.
Length
Compares how many characters each line contains. Lines of equal length are ordered A to Z.
Case, Whitespace, Duplicates, and Blank Lines Explained
Common Line-Sorting Examples
Names A to Z
A to Z
Input
Charlie alice Bob
Output
alice Bob Charlie
Numbers ascending
Numeric ascending
Input
100 7 10 2
Output
2 7 10 100
Natural sort
Natural sort
Input
item10 item2 item1
Output
item1 item2 item10
Length sort
Length ascending
Input
orange a cat
Output
a cat orange
Reverse text sort
Z to A
Input
apple zebra pear
Output
zebra pear apple
Remove blanks
A to Z, remove empty lines
Input
banana apple orange
Output
apple banana orange
Preserve header
A to Z, preserve first line
Input
Name Bob Alice
Output
Name Alice Bob
Deduplicate
A to Z, remove duplicates
Input
pear apple Pear apple
Output
apple pear
Frequently Asked Questions
Related tools