UTILYARD
guides

How to Reverse Text

The difference between reversing characters, words, and lines — plus how Unicode upside-down text works and when each mode is useful.

The four reversal modes

"Reversing text" is ambiguous — it can mean four different things depending on what unit you reverse. Each produces a completely different result.

1. Reverse characters — mirror the entire character sequence

The entire string is read backwards, character by character. Spaces, punctuation, and newlines are treated just like any other character.

"Hello, world!"  →  "!dlrow ,olleH"

Use for: palindrome testing, encoding puzzles, checking if a string is its own reverse.

2. Reverse words — keep characters intact, swap word order

Words are split on whitespace, then rejoined in reverse order. Each individual word stays intact; only the sequence changes.

"The quick brown fox"  →  "fox brown quick The"

Use for: sentence scrambling, interview problems, generating test cases for parsers.

3. Reverse lines — keep each line intact, swap line order

Splits on newlines, reverses the list of lines, then rejoins. Each line's content is untouched; only the order changes.

Line 1          Line 3
Line 2    →     Line 2
Line 3          Line 1

Use for: reversing a numbered list, showing a stack trace in chronological order, flipping a log file.

4. Flip characters — substitute Unicode upside-down lookalikes

This is not a true reversal — each character is individually replaced by a Unicode character that resembles it upside-down, and the sequence is also reversed so the whole string appears flipped when read.

"hello"  →  "ollǝɥ"

Use for: creative typography, social media bios, decorative text, puzzles.

How Unicode upside-down text works

Unicode contains thousands of characters beyond the basic Latin alphabet — many of which happen to resemble flipped or rotated versions of common letters. Flip mode exploits this by mapping each standard character to its nearest lookalike:

a → ɐ    b → q    c → ɔ    d → p    e → ǝ
f → ɟ    g → ƃ    h → ɥ    i → ᴉ    j → ɾ
k → ʞ    l → l    m → ɯ    n → u    o → o
p → d    q → b    r → ɹ    s → s    t → ʇ
u → n    v → ʌ    w → ʍ    y → ʎ    z → z

The result is valid Unicode text and works anywhere Unicode is supported — social media, messaging apps, documents. However, it's not truly mirrored — some letters like l, o, s, and x are symmetric and map to themselves.

Note: Flip mode also reverses the character order so the flipped result reads correctly when physically rotated 180°. Without reversing, each character would be upside-down but the words would still read left to right.

Reversing text in code

For each mode, here's the standard implementation across common languages:

// JavaScript
const reverseChars = s => s.split('').reverse().join('')
const reverseWords = s => s.split(/s+/).reverse().join(' ')
const reverseLines = s => s.split('
').reverse().join('
')

# Python
reverse_chars = lambda s: s[::-1]
reverse_words = lambda s: ' '.join(s.split()[::-1])
reverse_lines = lambda s: '
'.join(s.splitlines()[::-1])

Note: JavaScript's split('').reverse().join('') does not correctly handle multi-byte Unicode characters (emoji, some non-Latin scripts). For Unicode-safe reversal, use the Intl.Segmenter API or a library like grapheme-splitter.

Try it: Reverse Text
Reverse characters, words, or lines — or flip text upside-down with Unicode substitution.
Open tool →

Frequently asked questions

Does reversing words preserve punctuation?
Yes. Words are split on whitespace, so punctuation attached to a word stays with it. "Hello, world!" reversed by words becomes "world! Hello," — the comma stays on "Hello" and the exclamation mark stays on "world".
How is reversing characters different from reversing a palindrome check?
Reversing characters and checking for palindromes use the same operation — reverse and compare. But palindrome checking typically normalizes first (removes spaces, punctuation, and case) before comparing. Reversing characters here is literal: no normalization, just a pure character-sequence flip.
Can I reverse multiline text with each mode?
Yes. Reverse Lines reverses line order across all lines. Reverse Characters reverses the entire sequence including newlines. Reverse Words reverses all words treating the whole text as one word list (ignoring line breaks as separators).
Why do some flipped characters look different across devices?
The Unicode upside-down characters used by flip mode are standard Unicode code points, but their rendering depends on the font. If a font doesn't include a glyph for a specific code point, the OS substitutes from another font — which may look slightly different. The result is consistent in code but may vary visually.