Text Reverser
Reverse text by character, word or line, with correct emoji handling.
Output updates as you type.
Features
- Four reversal modes
- Grapheme-aware, emoji and combining accents stay intact
- Automatic palindrome detection
- Feed the result back in with one click
How to use it
- Type or paste your text.
- Choose what to reverse: characters, words or lines.
- The result updates immediately.
- Copy it, or press Use result as input to reverse again.
Why reversing a string is harder than it looks
The obvious approach, str.split('').reverse().join(''): is subtly broken. JavaScript strings are sequences of UTF-16 code units, and any character outside the Basic Multilingual Plane occupies two of them. Splitting on code units tears those pairs apart, so reversing a string containing an emoji produces replacement characters instead of the emoji.
Combining marks cause a second problem. The letter é can be a single code point, or it can be a plain e followed by a combining acute accent. Reverse the second form naively and the accent detaches, landing on whatever character now precedes it. Flag emoji, skin-tone modifiers and family sequences are made of several code points joined by zero-width joiners and break the same way.
This tool uses Intl.Segmenter where the browser supports it, which splits text into grapheme clusters, what a reader would call a character, rather than code units. Where it is unavailable, it falls back to a code-point split, which at least keeps surrogate pairs together. That handles emoji correctly even if some exotic combining sequences still shift.
Frequently asked questions
Related tools
Further reading
Read the full guide on the 123MiniApps blog.