Skip to main content
CalcChef

Reverse String

Reverse text by character, word order, letters in each word or line order. Emoji, flags and accented letters stay whole instead of breaking apart. How it works

Use the Reverse String

Example: stressed becomes desserts

13 characters, 2 words and 1 line reversed.

A character here is what you see as one: an emoji, a flag or a letter with its accent moves as one piece.

About the Reverse String

Reversed by character, “Hello, World!” becomes “!dlroW ,olleH”. To reverse text by word order, by the letters inside each word or by line order, pick that mode instead. An emoji, a flag or a letter with its accent always moves as one character, so none of them breaks.

One input, four modes

Reverse“one two three / four five”“Hello, World!”
Every characterevif ruof / eerht owt eno!dlroW ,olleH
Word orderthree two one / five fourWorld! Hello,
Letters in each wordeno owt eerht / ruof evif,olleH !dlroW
Line orderfour five / one two threeHello, World!

A “/” stands for the line break between the two lines of the first input. A one-line text is unchanged by Line order.

Text that reversing by code point breaks

TextReversed hereReversed by code point
café (e + combining U+0301)éfacU+0301 first, on no letter, then efac
🇸🇪 (flag of Sweden)🇸🇪 (flag of Sweden)🇪🇸 (flag of Spain)
🇨🇦 (flag of Canada)🇨🇦 (flag of Canada)🇦🇨 (flag of Ascension Island)
👍🏽 (thumbs up, medium skin tone)👍🏽🏽👍 (skin tone split off)
a👨‍👩‍👧b (family: man, woman, girl)b👨‍👩‍👧ab👧‍👩‍👨a (not an emoji in the Unicode list)

“By code point” is the common JavaScript one-liner Array.from(text).reverse().join(""). A flag is a pair of regional indicator letters, so swapping the pair can name another country.

Frequently asked questions

How do I reverse the order of words in a sentence?
Choose Word order. “one two three” becomes “three two one”, and each line is reversed on its own. Spaces stay where they were, leading spaces included (“ a b” becomes “ b a”), and punctuation moves with its word, so “Hello, World!” becomes “World! Hello,”.
How do I reverse a string in JavaScript without breaking emoji?
str.split("").reverse().join("") reverses UTF-16 code units and cuts most emoji into broken halves. [...str].reverse().join("") keeps code points whole but still splits what you see as one character: the flag of Sweden 🇸🇪 turns into the flag of Spain 🇪🇸. Split the text with Intl.Segmenter at grapheme granularity and reverse the segments, which is what this tool does. MDN lists Intl.Segmenter as working across current browsers since April 2024.
How do I reverse a list so the last line comes first?
Choose Line order. “first” and “second” on two lines come back as “second” and “first”, each line spelled as before. Windows line breaks (CR LF) come back as plain line feeds.
Is there a limit on how much text I can reverse?
The first 30,000 UTF-16 code units are reversed, and the page warns that the rest is left out. A plain letter is one unit and most emoji are two, so of a text of 20,000 smiley emoji (40,000 units) the first 15,000 are reversed.
Is a reversed sentence a palindrome?
Only when it reads the same both ways exactly as typed. Reversed by character, “A man, a plan, a canal: Panama” becomes “amanaP :lanac a ,nalp a ,nam A”. The letters match only once case, spaces and punctuation are ignored, which the Palindrome Checker does and this tool does not.
What is a word that spells another word backwards called?
A semordnilap, such as stressed and desserts or diaper and repaid. Wiktionary notes that the term is itself palindromes spelled backwards.

Related Tools

View all tools