Reverse String Online
This example shows the reverse operation from String Tools, pre-loaded with “Hello, World!”. Paste any text and see it reversed instantly, with proper handling of Unicode and emoji characters.
How It Works
The tool splits the input into an array of grapheme clusters (visual characters), reverses the array order, and joins them back into a string. This approach handles characters that span multiple code points, such as emoji with skin tone modifiers or combining diacritical marks.
ASCII vs Unicode Reversal
For simple ASCII text like Hello, reversal is straightforward: each byte corresponds to one character. But Unicode text can contain characters made of multiple bytes or combining characters. A naive byte-level reversal of cafe\u0301 (cafe with an accent) would produce garbage. This tool handles that correctly.
Palindrome Detection
A common use case for string reversal is palindrome checking. A palindrome reads the same forwards and backwards. To check if your text is a palindrome, reverse it and compare:
Original: racecar
Reversed: racecar
Match? Yes
Case-insensitive palindrome checking requires normalizing both strings to the same case before comparing.
Practical Uses
String reversal appears in algorithms like the “reverse and check” approach for palindromes, certain checksum calculations, and text formatting tasks. It is also a standard exercise for testing understanding of Unicode string handling.
How to Use
- Paste any text into the input area
- The reversed output appears instantly in the result area
- Copy the reversed text using the copy button
Common Questions
Can I reverse each word in a sentence separately?
The current operation reverses the entire input as one string. To reverse individual words, paste each word separately or use a regex-based find and replace with a reversal pattern.
Does reversing affect whitespace?
Yes. Leading spaces become trailing spaces and vice versa. If your text has intentional whitespace, be aware that reversal changes its position. Trimming the input before reversing eliminates this.
How do I undo a reversal?
Reversing the output a second time returns the original text. The operation is its own inverse.