Reverse text

Reverse the whole block or each line character by character (Unicode).

Overview

Reversing text seems trivial until you drop an emoji in the middle of a sentence. Characters that look simple on screen are often represented by more than one code unit: surrogate pairs for code points above U+FFFF, combining sequences for diacritics, and emoji modifier sequences turn what looks like a single character on screen into a cluster of bytes that, naively reversed, becomes unreadable garbage.

Mirror writing has a long history. Leonardo da Vinci wrote his notebooks entirely right to left, possibly to protect his notes from casual readers or simply because he was left-handed. Boustrophedon script, used in archaic Greek inscriptions, alternated writing direction on each line like an ox plowing a field — the name comes from exactly that image. Palindromes exist in virtually every language: racecar and a man a plan a canal Panama are classic English examples.

In development contexts, reversing text has real uses: debugging string algorithms, demonstrating that a parser is direction-agnostic, generating mirrored placeholders for RTL layout tests (right-to-left scripts like Arabic and Hebrew), and performing parity checks in text processing. For actual RTL scripts, Unicode provides the Bidirectional Algorithm, which automatically determines display direction — simply reversing the characters does not produce the same effect.

This tool offers two modes: reverse the entire block so the last character becomes the first, or reverse each line independently. Internally, reversal is performed over code points, which handles surrogate pairs correctly in most cases.

Technical deep dive

Unicode and the illusion of a simple character

  • An emoji like 👨‍👩‍👧 can be formed by four separate code points joined by Zero Width Joiners — reversing byte by byte completely destroys the sequence.
  • Accented letters can be represented as a single code point (NFC form) or as a base letter plus a combining diacritic (NFD form). Naive reversal produces different results depending on the normalization form of the input.
  • Surrogate pairs encode code points above U+FFFF using two 16-bit values in UTF-16. Reversing by 16-bit unit without handling these pairs produces invalid sequences.
  • The correct approach is to iterate over code points, not code units. In modern JavaScript, the spread operator [...str] and Array.from(str) already iterate over code points.

Real-world use cases

  • RTL layout testing: designers working with Arabic or Hebrew frequently need mirrored text to check how an interface handles bidirectional content.
  • String algorithms: classic technical interview problems like palindrome checking, anagram detection, and subsequence matching rely on reversing or comparing reversed strings.
  • Simple obfuscation: reversal is the most primitive substitution cipher. It offers no real security, but it is useful for educational exercises.
  • Generating mirrored domain names and identifiers for testing systems that should be agnostic to text direction.
  • Entertainment and culture: hidden messages in songs, joke texts, and typographic logos frequently use reversal as a visual device.

Tool guide

  • What you are working with A Unicode string (may include emoji).

  • What the tool does Reverses character order for the whole block or, in another mode, each line separately.

  • Why use it Tests, toys, trivial obfuscation, exercises, or checking Unicode handling.

Code Snippets

Correct reversal by code points in JavaScript
// Iterates over code points, not code units
function reverseText(str) {
  return [...str].reverse().join('');
}

console.log(reverseText('hello'));    // olleh
console.log(reverseText('Hello 👋')); // 👋 olleH
Line-by-line reversal
function reverseLines(text) {
  return text
    .split('\n')
    .map(line => [...line].reverse().join(''))
    .join('\n');
}

Sample

Hello → olleH

FAQ

What is this tool for?

It runs fully in your browser: useful to validate, format, or convert data in everyday development.

Are my inputs sent to a server?

Processing happens locally with JavaScript. We do not store what you paste into the text areas.

Can I use this for real production data?

Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.