Text Reverser

Reverse text by characters, words or lines, or flip letters inside each word — handling the emoji and accents that naive reversal corrupts.

The obvious way to test a reverse function proves nothing

Start here, because it is the trap. The natural check is to reverse twice and see whether you get the original back. Every method passes — reversing a sequence twice restores its order whatever the sequence is made of. Across all 7 samples below, three different implementations all round-trip perfectly, including on the samples they mangle.

The only test that separates them is comparing a single reversal against what a reader would call reversed — which means reversing by the units a reader perceives:

MethodRound-tripsOne reversal correct
by code unit — split('')always2 of 7
by code point — Array.from()always3 of 7
by grapheme — Intl.Segmenteralways7 of 7

This page used to use the middle one. That is a real improvement on the naive version — every code point stays whole, so a pasted emoji survives — and it is where most careful implementations stop. It is still not what a reader means, so the tool above now defaults to the last row and lets you pick the other two to watch them fail.

Where the middle answer still goes wrong

A grapheme cluster is one perceived character that may be several code points: a letter plus a combining accent, an emoji plus a skin tone, a flag, a family joined by invisible joiners. Reversing by code point takes those apart.

SampleClustersBy code unitBy code pointCorrect
plain ASCII — hello 5 olleh olleh olleh
a precomposed accent — café 4 éfac éfac éfac
a combining accent — café 4 ́efac ́efac éfac
an emoji — 😀ab 3 not valid text ba😀 ba😀
a flag — 🇺🇸 1 not valid text 🇸🇺 🇺🇸
a family, joined — 👨‍👩‍👧 1 not valid text 👧‍👩‍👨 👨‍👩‍👧
a thumbs-up with a skin tone — 👍🏽 1 not valid text 🏽👍 👍🏽

4 of the 7 come out wrong here, and the failures are not subtle once you look. The accent detaches and lands on the wrong letter. The skin tone comes out in front of the hand it was modifying. The people inside a single family emoji are reordered. And three of those samples are one cluster — a single character, which reversed should be itself.

The by-code-unit column says "not valid text" where the result contains half of a character. That is not a formatting choice: such a string cannot be stored as UTF-8 at all, so printing it here would show you a replacement character rather than what actually happened.

And one case that should end the argument

A flag is two regional indicator letters. The flag of the United States is the letters U and S. Reverse those two letters and you get S and U — which is itself a valid flag sequence, the Soviet Union:

Shows asLettersClusters
input🇺🇸U S1
reversed by code point🇸🇺S U1

Not a broken character. Not a placeholder box. A different, real, well-formed flag, rendered cleanly by the same font. Which is exactly why "it looked fine when I tested it" is not evidence of anything — the output here is well-formed and wrong at the same time.

None of this touches ordinary text. On the quick brown fox all three methods agree exactly, character for character, and reversing text is nearly always a puzzle or a party trick where that is all you need. It matters when you reverse text in order to compare it, hash it, or store it — and then it matters completely.

How to use

  1. Paste your text.
  2. Choose what to reverse: characters, words, or lines.
  3. Read the result.
  4. Check that emoji and accented characters survived intact.

Frequently asked questions

Why does reversing text sometimes corrupt emoji?

Because a naive reversal works on storage units rather than characters. Emoji and many non-Latin characters occupy more than one unit, so reversing blindly splits them into invalid fragments that render as replacement squares. Correct reversal has to work on whole characters.

What about accented characters?

Same problem, different cause. An accent can be stored as a separate combining character following its base letter, so reversing moves the accent onto the wrong letter — or onto nothing. This is why reversal has to respect grapheme clusters, not just code points.

What is a palindrome check?

Comparing text against its own reverse. Doing it properly means normalising first — usually stripping punctuation, collapsing whitespace and ignoring case — since 'A man, a plan, a canal: Panama' is a palindrome only after that treatment.

What is reversing text actually useful for?

Puzzles and word games mostly, plus the occasional data task where a field is stored back to front. It is also a standard programming exercise precisely because doing it correctly for real Unicode text is much harder than it first appears.

Does reversing hide text from search?

Not meaningfully. It is trivially undone and offers no security whatever. Anyone treating reversed text as obscured should assume it is fully readable.

What is right-to-left text?

Arabic, Hebrew and several other scripts are written right to left, and the display order is handled by the text rendering system rather than by storing the characters backwards. Reversing such text does not convert it — it corrupts it.

🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.