Sort Lines Alphabetically

Sort multiple lines of text in alphabetical order with powerful options including reverse sorting, case-insensitive mode, numeric sorting, and automatic duplicate removal. Process runs instantly in your browser—nothing is uploaded.

Sorted output

FreeNo sign-upPrivate — runs in your browser, nothing is uploaded

Quick answer

Paste lines of text and sort them alphabetically A-Z or Z-A. The tool also removes duplicates, handles case-insensitive sorting, and supports numeric sorting where lines that start with a number are ordered by its value instead of alphabetically.

Formula & method

Paste or type multiple lines into the text area. Lines sort A-Z (ascending) by default; tick Z → A for descending order, then enable any combination of options: case-insensitive to ignore uppercase/lowercase differences, numeric sort to order numbers by value, or remove duplicates to keep only unique lines. Results display instantly as you type or adjust settings.

Examples

Example 1: Basic Alphabetical Sort

Input
banana apple cherry
Result
apple banana cherry
Why
Lines are sorted in standard A-Z order, comparing the first character of each word.

Example 2: Case-Insensitive Reverse Sort with Case Variants

Input
Zebra apple ZEBRA Apple banana
Result
ZEBRA Zebra banana Apple apple
Why
Z-A reverse sort ignoring case treats 'Zebra' and 'ZEBRA' as equal (sorts together), then 'apple' and 'Apple' together. Equal lines keep their input order, and the final Z-A reversal flips that order, so ZEBRA lands before Zebra.

Example 3: Numeric Sort Removing Duplicates

Input
10 apples 2 pears 10 apples 1 plum
Result
1 plum 2 pears 10 apples
Why
Numeric sort reads the number at the start of each line, so 1 comes before 2 before 10 (alphabetically '10' would come before '2'). Remove duplicates eliminates the second '10 apples'.

When to use this tool

  • Organizing lists of names, items, or categories alphabetically for reports, inventories, or documentation.
  • Cleaning up disorganized data from spreadsheets, exported logs, or form submissions by sorting and removing duplicate entries.
  • Preparing sorted lists for code, configuration files, or URLs where consistent ordering helps with version control diffs and readability.

Common mistakes

  • Forgetting to enable numeric sort for numbered lines: '10 apples' appears before '2 pears' in alphabetical mode because '1' comes before '2'. Numeric sort only reads a number at the start of a line, so 'file10' still sorts as text.
  • Expecting case-sensitive mode to put all uppercase lines first: lines are compared with locale-aware rules, so 'apple', 'Apple' and 'APPLE' stay together either way; case-sensitive mode only orders those ties, typically lowercase first.
  • Assuming duplicate removal ignores small differences: the tool only removes completely identical lines. If lines differ by whitespace, capitalization (even in case-insensitive mode), or any character, they are treated as unique.

Frequently asked questions

Does this tool upload my text to a server?

No. All sorting happens in your browser. Your text never leaves your device.

What's the difference between standard alphabetical sort and numeric sort?

Standard sort compares characters left-to-right: '10' comes before '2' because '1' < '2'. Numeric sort reads the number at the start of each line and orders by its value: 2 < 10. Use it for lists that begin with numbers; lines that start with letters are still sorted as text.

How does case-insensitive sorting work?

It treats 'A' and 'a' as equivalent for sorting purposes. Lines are still returned with their original case. It is on by default; without it, words still sort alphabetically and only same-spelling ties are ordered by case.

Can I sort in reverse (Z-A) order?

Yes. Choose the Z-A option to reverse the sort direction. This works with any combination of other options like numeric sort or duplicate removal.

What counts as a duplicate for removal?

An exact match: the entire line must be identical, character-for-character, including spacing. 'apple' and 'apple ' (with trailing space) are different and both kept.

Can I sort numbers that have leading zeros or mixed formats?

Numeric sort recognizes numbers regardless of leading zeros. '007' and '7' are treated as the same value (7) and sorted together, preserving the original text format in the output.

Sources & references

External references open in a new tab. We are independent and not affiliated with these organizations.

  • Free
  • No sign-up
  • Runs entirely in your browser — nothing is uploaded.
  • Formula and method shown above

Provided “as is” for general information only — results may be inaccurate, so verify before you rely on them. No warranty; use at your own risk.

Built and reviewed by HIFreeTools against the formula shown above and any authoritative references cited on this page. See our methodology and editorial standards below.

Related tools

Embed this tool on your site

Free to embed, no sign-up. Paste this code where you want the tool to appear: