Reverse Words Tool

Flip the word order of any text.

How it is calculated

The tool trims the text and splits it at every run of whitespace (spaces, tabs and line breaks), reverses the list and joins it back with single spaces. A word is anything between whitespace, so punctuation stays attached to the word it touches: Hello, keeps its comma and moves with it. Letters inside a word are not changed, and capital letters stay where they are on each word. Because all whitespace becomes a single space, extra spaces and line breaks in the input are lost and the output is one line. Empty text, or text with only spaces, returns no result. This reverses word order only; it does not reverse the letters of each word.

Worked example

Take the sentence: Hello, world! How are you today? It splits into six pieces: Hello, / world! / How / are / you / today? The list is reversed to today? / you / are / How / world! / Hello, and joined with single spaces. The result is today? you are How world! Hello,. Notice that the question mark now sits in the middle of the line and the comma ends it, because punctuation travels with its word rather than staying at the end of the sentence.

Try this example →

Common mistakes

  • Expecting the letters of each word to be reversed. This tool flips only the order of the words, so Hello stays Hello, not olleH.
  • Expecting punctuation to stay at the end of the sentence. A full stop or question mark is attached to its word and moves with it.
  • Pasting several lines and expecting the lines to stay separate. Line breaks count as spaces, so everything is merged into one reversed line.
  • Expecting capital letters to be corrected. The first word of the original keeps its capital and ends up last, so the new first word may be lowercase.
  • Relying on exact spacing. Double spaces and tabs are collapsed to single spaces, so the output does not preserve the original layout.

About this calculator

This tool reverses the order of words in a sentence while keeping each word itself intact, so "the quick brown fox" becomes "fox brown quick the." Unlike reversing individual characters, this operation works at the word level, splitting text on spaces, flipping the sequence, and rejoining it.

It's used for word-order puzzles and language games, for generating novelty or attention-grabbing social media text, and by writers and editors experimenting with sentence structure or checking how a phrase reads in reverse order for stylistic effect. Programmers also use a working reverse-words example as a quick reference or sanity check when implementing similar string-splitting and array-reversal logic in their own code.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    The tool finds words by looking for whitespace, so it suits languages that put spaces between words. Text in Chinese or Japanese, which is usually written without spaces, comes back as one unbroken block and is therefore unchanged. The same applies to a long string with no gaps, such as a URL. Separately, the capital letter of the first word does not move with it. What other word-level transformation would you like to see, such as sorting or shuffling?

Popular calculators

All Calculators