/tools/text-reverser

Text Reverser

Three kinds of reversal, and a palindrome check. Emoji and accented characters survive intact, which naïve reversal breaks.

Text ReverserRuns in your browser
Reverse by

How to use the Text Reverser

  1. Type or paste the text you want to reverse.
  2. Choose whether to flip characters, word order, line order, or the letters inside each word.
  3. Copy the result, or press Check palindrome to test whether the text reads the same both ways.

Why reversing a string is harder than it looks

The textbook one-liner — str.split('').reverse().join('') — is subtly broken. It splits on UTF-16 units rather than characters, so any character outside the Basic Multilingual Plane is torn in half. Reverse "I 👍 this" that way and the emoji becomes two pieces of invalid text.

This tool uses Array.from, which iterates by code point and keeps emoji and rare scripts intact. One case remains genuinely unsolvable in a general way: combining marks. A letter with a separately encoded accent, or a family emoji built from several joined code points, can still split apart. Handling those properly needs grapheme cluster segmentation.

Palindromes and what counts

A palindrome reads the same forwards and backwards. Conventionally, punctuation, spaces and capitalisation are ignored — which is why "A man, a plan, a canal: Panama" qualifies despite the commas and colon.

The check here strips everything that is not a letter or digit, lowercases the rest, and compares. It works across scripts, so palindromes in Cyrillic or Greek are detected the same way.

Frequently asked questions

Does it produce right-to-left text?

No. Reversing characters changes the order of the characters themselves. Displaying text right-to-left is a rendering direction, set with the CSS direction property or a Unicode marker.

Will my emoji survive?

Single emoji, yes. Compound sequences like family emoji or skin-tone modifiers may split, because they are several joined code points rather than one.

What is the difference between reversing words and reversing each word?

Reversing word order turns "hello big world" into "world big hello". Reversing each word's letters gives "olleh gib dlrow". The first keeps every word readable; the second keeps the sentence order.

Are line breaks preserved?

In word and line modes, yes. Reversing characters flips the whole text including newlines, so paragraph structure inverts along with everything else.

Related tools