Text & writing
Why Reversing Text Can Break Emoji
Reversing a string sounds like the simplest possible text operation — just read it backwards. But many common ways of doing it break emoji, flags, and accented letters, producing boxes, question marks, or the wrong characters. This guide explains why, and how to reverse text safely.
Ready to try the tool this guide describes?
What “a character” means
Computers store text as code units, and one visible character can be several of them. In JavaScript, text is stored in UTF-16, where many emoji need two code units. A visible character can also be several Unicode code points: an emoji with a skin tone is a base emoji plus a modifier, a family emoji joins several emoji with zero-width joiners, and a flag is two regional-indicator letters.
How naive reversal goes wrong
Flags show the problem neatly: the United Kingdom flag is the regional-indicator letters G and B. Reversing the code points gives B then G — which is the flag of Bulgaria.
| Method | What it reverses | What breaks |
|---|---|---|
| Reversing code units | UTF-16 units | Emoji outside the basic range turn into invalid characters. |
| Reversing code points | Unicode code points | Skin tones detach, joined emoji split apart, accents move to the wrong letter. |
| Reversing grapheme clusters | User-perceived characters | Nothing — each visible character stays whole. |
Reversing correctly
The safe approach is to split the text into grapheme clusters — the units Unicode defines for user-perceived characters — and reverse those. Browsers provide this through Intl.Segmenter with grapheme granularity, which is what the Looty Tools Reverse Text tool uses.
Testing a reverser
- Reverse a skin-tone emoji such as 👍🏽 and check that the tone stays attached.
- Reverse a family emoji and check that it stays one picture.
- Reverse a flag and check that it is still the same country.
- Reverse text twice and confirm you get the original back.
Why Reversing Text Breaks Emoji FAQ
- Why do emoji turn into boxes when text is reversed?
- The reverser split the emoji into code units or code points, producing invalid or separated characters.
- What is a grapheme cluster?
- Unicode’s term for a user-perceived character — what a reader sees as one character, even if it is made of several code points.
- Why did my flag change country when reversed?
- Flags are pairs of regional-indicator letters. Reversing the pair gives a different country code, such as GB becoming BG.
- How do I reverse text safely in JavaScript?
- Split it into grapheme clusters with Intl.Segmenter using grapheme granularity, reverse the array, and join it back together.
- Does reversing twice always restore the original?
- With grapheme-aware reversal, yes. Naive methods can permanently damage characters.
Related guides
- Palindromes ExplainedWhat palindromes are, why phrase palindromes ignore spaces and punctuation, how to check one step by step, and related word reversals.
- Reversed, Mirrored, Upside-Down TextThe difference between reversed text, reverse line order, mirrored text, and upside-down text, and how each one is created.
