ForHosting KIT · Text & AI

Reverse word order

“the quick brown fox” becomes “fox brown quick the”: the words swap places while each one keeps its letters, so you never get “xof nworb”. Punctuation travels with its word. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Text
hello world from pavilion
You get
Result
pavilion from world hello
Input
hello world from pavilion
Reversed
pavilion from world hello
Original words
hello, world, from, pavilion

A reverse-word-order tool takes a sentence or phrase and puts the last word first, the first word last, and leaves every word’s letters unchanged. Writers checking rhetoric, developers writing string-manipulation exercises, and teachers grading “reverse the words but not the letters” drills all need the same deterministic mapping.

What reverse word order means and how words are split

Reversing word order is the transform that takes a sequence of tokens separated by whitespace and returns those same tokens in the opposite sequence while preserving the character sequence inside each token. The classic classroom example is the sentence the quick brown fox: after reverse word order you get fox brown quick the, not xof nworb kciuq eht, which would reverse characters inside each word instead. This capability implements the first intent only.

Remaining input is split on any run of spaces, tabs, or newlines so multiple separators never create empty tokens. Each non-empty token is kept exactly as written—case, digits, and attached punctuation stay on that token—so Hello, world! becomes world!

Hello, with the comma and exclamation mark still glued to their original words. A single-word input is valid and returns that word unchanged, which is the correct reverse of a one-element list.

Practical tips, limits, and when to use this tool

Use this capability when the search intent is reverse word order, reverse words in a sentence, flip word order, or keep each word intact while reordering. Paste a headline, a song lyric fragment, or a coding interview sample, reverse once, and drop the result into a worksheet answer key or a unit-test expected value. Keep punctuation expectations clear: commas, periods, and quotes attached to a word travel with that word because splitting is whitespace-only—if you need punctuation as separate tokens, tokenize first with a dedicated tokenizer.

This landing is not a reverse-string tool that flips every character, not a palindrome checker, and not a natural-language reordering model that rewrites grammar. Prefer a character-reverse utility when the exercise says reverse the string; prefer this capability when the exercise says reverse the order of the words. When teaching, compare the same phrase under character reverse versus word reverse so students see why the two intents need different tools and different SEO landings.

Classroom answer keys

Teachers reverse sample sentences once to publish deterministic keys without reversing letters inside each word by mistake.

Copy and layout experiments

Writers and designers flip word order on a phrase to preview emphasis or layout stress without editing character by character.

Does reverse word order reverse letters inside each word?

No. Only the sequence of words changes. Characters inside each word stay in their original order.

How are multiple spaces handled?

Runs of spaces, tabs, or newlines are treated as a single separator. Output words are joined with one space.

What about punctuation?

Punctuation attached to a word stays on that word because splitting is whitespace-only.

Is the reverse word order tool free?

The browser tool is free and runs locally.

Does it reverse each line separately?

No, a line break separates words just like a space does, so the words of every line are reversed as one sequence. If each line should stay on its own, run the lines through one at a time.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/str/reverse-words

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/str/reverse-words \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"hello world from pavilion"}'
{
  "text": "hello world from pavilion"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "str.reverse_words",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_chars100000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Empty or whitespace-only input is rejected with a clear invalid_input error so pipelines never treat a blank field as a successful transform.

What reverse word order means and how words are split

Leading and trailing whitespace is trimmed first; if nothing remains, the call fails with invalid_input rather than returning an empty success string.

How to call the API and what the response contains

Prefer sending the raw phrase rather than pre-collapsing spaces when you want the fixed rule set; the converter normalizes separator runs on the way in. Send a JSON body with a required string field text (aliases input, value, string, s, and phrase). The value must be a non-empty string after whitespace is trimmed and must not exceed one hundred thousand characters so a single request cannot exhaust Worker or browser memory on huge paste dumps. On success the response echoes input as the original string you sent, text as the trimmed working string, result and reversed as the same reordered phrase, original_words as the array of tokens before reverse, reversed_words as the array after reverse, word_count as the integer token count, and message as a short English summary that reports how many words were reordered. Failed validation—missing text, a non-string value, an oversize payload, or empty content after trim—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price.

Practical tips, limits, and when to use this tool

Round-trip checks for tests are easy: feed hello world from pavilion and expect pavilion from world hello with word_count four; feed a single token and expect the same token; deliberately send empty string or spaces to confirm invalid_input and the message that asks for a non-empty string. Failed tasks that return invalid_input do not consume prepaid balance, which keeps form validation and CI negative tests cheap.

Coding kata and interview fixtures

Generate expected outputs for “reverse words in a sentence” exercises and assert blank input raises invalid_input in CI.

What happens with empty or whitespace-only input?

The tool returns invalid_input. Provide a non-empty string after trimming spaces.

Read the full KIT documentation →