How to use the sort & clean lines tool
- Paste your list. Drop in text or a file with one item per line (or change the input separator).
- Pick a sort order. Alphabetical, natural (so “Item 2” comes before “Item 10”), numeric, by length, reversed or shuffled randomly.
- Tidy the items. Trim spaces, remove empty lines and duplicates, change the case, add prefixes or suffixes, wrap items in quotes or number them.
- Copy the result. Copy it or download it as a text file, or use “Use output as input” to chain more clean-ups.
Common uses
- Alphabetise names, tags, glossary terms or reference lists
- Sort numbers correctly (2 before 10) with natural or numeric sorting
- Randomise the order of a list for draws, quizzes or testing
- Prepare lists for code: add quotes and commas around every item
How the sort orders differ
The same made-up list, Item 10, item 2, Item 1, banana, 7, 30, comes out differently depending on the order you pick:
| Sort order | Result | Good for |
|---|---|---|
| A → Z (alphabetical) | 30, 7, banana, Item 1, Item 10, item 2 | Plain word lists |
| Natural | 7, 30, banana, Item 1, item 2, Item 10 | Names that end in numbers (Item 2 before Item 10) |
| Numeric low to high | 7, 30, banana, Item 1, Item 10, item 2 | Lists of numbers; text that is not a number goes last, in alphabetical order |
| Shortest first | 7, 30, banana, Item 1, item 2, Item 10 | Spotting very short or very long entries (ties are alphabetical) |
Plain alphabetical sorting compares character by character, so “30” comes before “7” because “3” comes before “7”. That is the reason natural and numeric sorting exist. Alphabetical sorting here also ignores letter case, so “banana” and “Item 1” are ordered by their letters, not by capitals first. Natural sorting reads digits inside text as numbers, which is why “Item 2” comes before “Item 10”.
Sorting and cleaning in one pass
The options work together in a fixed order: split the input into items, trim and drop blanks, remove duplicates, sort, change case, then add prefixes, quotes and numbering. That means you can paste a messy column and get a numbered, de-duplicated, alphabetical list in one step. To turn the result into a comma separated list for a query, use the List Converter or read the guide to comma separated lists.
Limits
- Alphabetical order follows your browser’s language rules, so accented letters and non-Latin alphabets sort the way your browser’s locale expects.
- Numeric sorting treats text that is not a number as larger, and places it at the end.
- Shuffle gives a different random order every time the input or options change.
Frequently asked questions
How do I sort lines alphabetically?
Paste the list and choose A → Z (or Z → A). Sorting ignores letter case so Apple and banana sort the way you expect.
What is natural sort?
Natural sort compares the numbers inside text as numbers, so “Item 2” comes before “Item 10” instead of after “Item 1”.
How do I sort numbers correctly?
Use “Numeric low → high” or “high → low”. Text lines that are not numbers are placed at the end.
Can I shuffle or randomise a list?
Yes, choose “Shuffle randomly”. Each change to the input or options produces a fresh shuffle.
Can I add numbers or quotes to each line?
Yes. “Number the items” adds 1., 2., 3. and “Wrap each item” adds quotes, brackets or backticks; combine with an output separator of comma to build code-ready lists.
Does it change my original text?
No. Your input is untouched; the sorted result appears in the output box.
More tools: Email Extractor · Compare Lists · Remove Duplicates · Sort Lines · List Converter