Skip to content
Back to all articles
Text3 min readNovember 20, 2026

How to Reverse Text: Letters, Words and Lines (Plus Code Examples)

Three kinds of reversing, how to do each online, in Excel, JavaScript and Python, palindromes, and why emoji break when text is reversed.

How to Reverse Text: Letters, Words and Lines (Plus Code Examples) article
In this guide
  1. The three kinds of reversing
  2. Online
  3. In Excel
  4. In JavaScript
  5. In Python
  6. Why emoji and some letters break
  7. Palindromes
  8. Reversed text is not mirrored or upside-down text
  9. Ideas for using reversed text

“Reverse text” can mean three different things, and the right one depends on what you are doing: writing a word backwards for a puzzle, flipping the order of words in a sentence, or turning a list upside down. Here is how to do each — online, in Excel and in code — and the one pitfall that trips up even experienced programmers.

The three kinds of reversing

ModeInputOutput
Reverse charactersHello worlddlrow olleH
Reverse wordsone two threethree two one
Reverse linesMonday / Tuesday / Wednesday (one per line)Wednesday / Tuesday / Monday
  • Characters — for puzzles, games, backwards captions and checking palindromes.
  • Words — for word games and re-ordering items written on one line.
  • Lines — for flipping a log, a chat export or a ranked list so the last item comes first.

Online

Paste your text into the free Reverse Text tool, choose Reverse Characters, Reverse Words or Reverse Lines, and copy the result. It updates as you type and runs in your browser.

Two details to know: reversing characters also reverses the order of lines, and reversing words joins everything with single spaces, so use Reverse Lines when the line structure matters.

In Excel

In Microsoft 365, this formula reverses the characters in cell A1:

=TEXTJOIN("", TRUE, MID(A1, SEQUENCE(LEN(A1), 1, LEN(A1), -1), 1))

SEQUENCE counts from the last position down to 1, MID picks one character at each position, and TEXTJOIN glues them back together.

To reverse the order of rows in a column, add a helper column numbered 1, 2, 3… and sort by it from largest to smallest, or use =SORTBY(A2:A20, ROW(A2:A20), -1).

In JavaScript

const reverseChars = (s) => [...s].reverse().join('');
const reverseWords = (s) => s.trim().split(/\s+/).reverse().join(' ');
const reverseLines = (s) => s.split('\n').reverse().join('\n');

Note the [...s] rather than s.split(''). That difference is the pitfall described below.

In Python

text[::-1]                          # characters
' '.join(reversed(text.split()))    # words
'\n'.join(reversed(text.splitlines()))  # lines

Why emoji and some letters break

Computers store text as a sequence of code units, and not every visible character is one unit:

  • Many emoji take two code units in JavaScript (a “surrogate pair”). Reversing with split('') swaps the two halves and produces garbage.
  • Flags are two characters (🇮🇳 is the regional letters I and N). Reverse them and you get a different flag — 🇳🇮, Nicaragua.
  • Accented letters can be a base letter plus a combining mark (e + ◌́). Reverse them and the accent jumps onto the wrong letter.
  • Hindi and other Indic scripts combine consonants, vowel signs and the virama into one visible syllable; reversing code units breaks those syllables apart.
  • Family and skin-tone emoji are several emoji joined by invisible joiners.

[...s] in JavaScript fixes the first problem but not the others. For truly correct reversal of what users see, split text into grapheme clusters with Intl.Segmenter:

const seg = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
const reverseVisible = (s) => [...seg.segment(s)].map((x) => x.segment).reverse().join('');

The simple rule for everyday use: reverse characters for plain English text; reverse words or lines when the text contains emoji, flags or non-Latin scripts.

Palindromes

A palindrome reads the same backwards: “level”, “racecar”, “madam”, and numbers like 12321. For phrases, ignore spaces, punctuation and capital letters:

  • “Never odd or even”
  • “Was it a car or a cat I saw?”
  • “A man, a plan, a canal: Panama”

To check one, remove spaces and punctuation, make it lower case with the Case Converter, then reverse it and compare. In code:

const isPalindrome = (s) => {
  const t = s.toLowerCase().replace(/[^a-z0-9]/g, '');
  return t === [...t].reverse().join('');
};

Reversed text is not mirrored or upside-down text

  • Reversed text uses normal letters in the opposite order: “olleH”.
  • Upside-down text replaces letters with Unicode look-alikes that appear rotated: “ollǝH”. Use Upside Down Text for that.
  • Mirror writing, like “AMBULANCE” on the front of an ambulance, flips each letter's shape. Plain text cannot do that; flip an image of the text with Flip Image.

Ideas for using reversed text

  • Treasure-hunt and escape-room clues
  • Classroom spelling and reading exercises
  • Quick checks for string-handling code
  • Reading a newest-first log in date order (reverse lines)
  • A playful username or caption
Was this article helpful?

Found this guide useful?

Share it with someone who is struggling with the same problem.

Free tool · No sign-up

Reverse Text

Reverse text three ways: flip the letters, reverse the order of words, or reverse the order of lines. Live result and one-click copy.

Open tool

Written by

Hemant Adhikari HemantInsights

Senior Software Engineer · Developer of Toolyconvert

I’m a senior software engineer from Dehradun, India, building websites since 2014. I designed and developed Toolyconvert, from the Next.js front end and headless WordPress back end to the tools themselves, and I review every guide before it goes live.