Format Code Now
/

Sort Words Alphabetically

TX-22

Paste a block of text and get its words back in alphabetical order, joined by spaces, new lines or commas. Use it for word lists, tags and keywords.

Runs in your browser. Nothing is uploaded.

Text

Sorted words

How to use it

  1. Paste your text into the input box. Words can be separated by spaces or line breaks.
  2. Choose A to Z or Z to A, and how to join the sorted words.
  3. Tick Ignore case, Sort numbers by value or Remove duplicate words as needed.
  4. Press Sort words, then copy the result or download it.

What counts as a word

The text is split at spaces, tabs and line breaks, and each piece is a word. Punctuation stays attached to the word it touches, so apple, and apple are different words and sort by their full text. If you want clean words, remove punctuation first. The original line breaks are not kept unless you choose New line as the join.

How the sort order is decided

Sorting uses the browser Intl.Collator with English rules. Accented letters sit next to their base letters, so é sorts near e. With Ignore case on, Apple and apple count as equal and keep their input order. With Sort numbers by value on, 2 comes before 10; with it off, 10 comes before 2 because the text is compared character by character. Z to A is the exact reverse of A to Z.

Questions people ask

How do I sort words alphabetically?

Paste the text, leave A to Z selected and press Sort words. The words come back in alphabetical order joined by spaces. Pick New line in Join words with if you want a list.

Can I sort words from Z to A?

Yes. Choose Z to A in the Order list. The result is the reverse of the A to Z order, except that words that are equal when case is ignored keep their input order, as they do in A to Z.

How do I remove duplicate words while sorting?

Tick Remove duplicate words. The first copy of each word is kept. With Ignore case on, Apple and apple count as the same word, so only the first one in your text stays.

Why does 10 come before 2?

By default text is compared one character at a time, so 1 comes before 2. Tick Sort numbers by value to put 2 before 10.

Does it keep punctuation?

Yes. Punctuation stays attached to its word and is sorted as part of it. A word followed by a comma is treated as a different word from the same word without the comma.

About this tool

Words are the pieces left after splitting on spaces, tabs and line breaks, so punctuation stays attached to the word it touches and sorts with it. Sorting uses the browser Intl.Collator with English rules, so letters with accents sort next to their base letter, and Z to A is the reverse order of A to Z, except that words that compare as equal (such as Apple and apple with Ignore case on) keep the order they had in your text in both directions. With Ignore case on, Apple and apple count as the same for sorting and for removing duplicates, and the first one in your text is kept. Line breaks in the input are lost unless you join with New line. Sorting is stable, so equal words keep their input order.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.