Text reverser
What is a Text Reverser?
Reversing text is useful more often than you might think: checking palindromes, reversing the order of log lines so the newest appear first, flipping a list, creating puzzles, or testing how your code handles Unicode. This tool reverses text in three ways: by characters, by words or by lines.
How to use it
- Paste or type your text.
- Choose the mode: characters, words or lines.
- Copy the result.
Examples
- Characters:
Hello worldbecomesdlrow olleH. - Words:
one two threebecomesthree two one. - Lines: a list of log entries from oldest to newest becomes newest to oldest, with each line unchanged.
The Unicode trap
A naive reverse in JavaScript, str.split('').reverse().join(''), works on UTF-16 code units, not characters. It breaks emoji and other characters outside the Basic Multilingual Plane into invalid halves, and separates accents written as combining marks from their letters. Reversing café 👍 that way can produce garbage. A correct approach splits text into grapheme clusters, the characters a user actually sees, for example with Intl.Segmenter.
Practical uses
- Palindrome checks: lowercase the text, remove spaces and punctuation, then compare it with its reverse. A man, a plan, a canal: Panama passes.
- Reversing lists exported in the wrong order.
- Command-line equivalents:
revreverses characters on each line andtacreverses line order.
Frequently Asked Questions
How do I reverse the order of lines?
Choose line mode. Each line stays intact, but the last line comes first.
Why does reversing text break emoji in some tools?
Many tools reverse UTF-16 code units, splitting emoji into invalid halves. Reversing by grapheme clusters keeps them intact.
How do I check if a word is a palindrome?
Lowercase it, remove spaces and punctuation, reverse it by characters and compare it with the original.
What is the Linux command to reverse text?
rev reverses the characters on each line, and tac prints the lines of a file in reverse order.