webby.tools

Reverse String

Type or paste any text below and the reversed output appears instantly — every character flipped from last to first.

Reversed Output

What Does "Reverse a String" Mean?

Reversing a string means writing it backwards — the last character becomes the first, the second-to-last becomes the second, and so on. Every character is preserved; only the order changes.

Input Reversed
hello olleh
Hello, World! !dlroW ,olleH
racecar racecar
12345 54321
Was it a car or a cat I saw was I tac a ro rac a ti saW

Notice that racecar reversed is itself — this makes it a palindrome. Spaces, punctuation, and numbers are all treated as regular characters and reversed along with letters.

How It Works

The algorithm is three steps:

  1. Split the string into an array of individual characters
  2. Reverse the array in place
  3. Join the array back into a single string

In JavaScript: str.split('').reverse().join('')

This works correctly for standard ASCII text. For strings containing Unicode emoji or multi-codepoint characters (like some accented letters or flag emoji), the split-reverse-join approach can break composite characters apart. For most practical use cases — reversing words, testing palindromes, encoding tricks — it works exactly as expected.

Common Uses

Palindrome testing — A string is a palindrome if it reads the same forwards and backwards. Reverse it and compare to the original: racecar === racecar ✔, hello === olleh ✗.

Simple obfuscation — Reversed text is trivially readable by reversing it again, but it's occasionally used in puzzles or games to hide a spoiler at a glance.

Programming practice — Reversing a string is one of the most common beginner coding interview questions. It tests understanding of arrays, loops, and string manipulation.

Encoding tricks — Some legacy systems or file formats store certain fields reversed (e.g. RTL language handling, certain barcode formats).

Frequently Asked Questions

Are spaces and punctuation reversed too? Yes — every character in the string is reversed, including spaces, punctuation, numbers, and newlines. Only the order changes; no characters are added or removed.

What about multi-line text? Each line break is treated as a character (\n), so multi-line text will have its lines flipped end-to-end as well as the characters within them. If you want to reverse lines independently, try the Reverse Lines tool.

What about reversing individual words instead of the whole string? This tool reverses the entire character sequence. To reverse the letters within each word while keeping word order, use Reverse Each Word. To flip the order of words while keeping letters forward, use Reverse Words.

Icons from Creative Fabrica

This website may contain affiliate links. If you click on an affiliate link and make a purchase, we may receive a small commission at no additional cost to you.