String Functions
String Reverse
Reverse the order of characters in any string. Unicode-aware — emoji and accented characters reverse cleanly.
About String Reverse
String Reverse flips the order of characters in a block of text. Paste text into the Source field, click Submit, and the Result field shows the input read backwards — words, spaces, punctuation, and line breaks are all reversed together, so hello world becomes dlrow olleh, not two separately-reversed words. The transform runs entirely in your browser; nothing you paste is sent to a server, so it's safe to use on text you wouldn't want leaving your machine, and results appear as soon as you click Submit rather than on every keystroke.
Under the hood it runs Array.from(input).reverse().join(''). Array.from on a string splits by Unicode code point rather than by UTF-16 code unit, so multi-byte characters — most emoji and other characters outside the Basic Multilingual Plane — stay intact instead of being torn apart. That matters because the more obvious one-liner, input.split('').reverse().join(''), splits by code unit: it reverses plain ASCII text correctly but corrupts any character stored as a surrogate pair. It's also why the output differs from PHP's strrev(), which reverses raw bytes and breaks multi-byte UTF-8 characters outright.
Reach for this when eyeballing a reverse-a-string coding-exercise fixture, sanity-checking your own reversal implementation against a known-good reference, generating quick reversed placeholder strings, or building a palindrome check by comparing a string to its reversed form. It also doubles as a quick demonstration of why split('').reverse().join('') is a common JavaScript interview trap — paste in a string containing an emoji and compare the result to what a naive split-based reversal would produce.
Examples
Input: Was it a car or a cat I saw?
Output: ?was I tac a ro rac a ti saWThis is the tool's own placeholder text — try it in the widget above.
const input = "a\u{1F600}b"; // a + 😀 + b
input.split('').reverse().join('');
// "b\uDE00\uD83Da" — surrogate pair torn apart, renders as garbage
Array.from(input).reverse().join('');
// "b\u{1F600}a" — correct; this is what String Reverse does internallysplit('') iterates UTF-16 code units; Array.from iterates Unicode code points.
function isPalindrome(s) {
const clean = s.toLowerCase().replace(/[^a-z0-9]/g, '');
return clean === Array.from(clean).reverse().join('');
}
isPalindrome('racecar'); // true
isPalindrome('A man a plan a canal Panama'); // true
isPalindrome('hello'); // falsePaste the cleaned string into the tool and compare the Result to the original by hand.
Frequently asked questions
How do I reverse a string in JavaScript?
The shortest correct one-liner is Array.from(str).reverse().join('') — splitting by Unicode code point keeps emoji and other multi-byte characters intact. The more common str.split('').reverse().join('') looks identical for plain ASCII text but corrupts any character stored as a UTF-16 surrogate pair.
Why does str.split('').reverse().join('') break on some strings?
split('') divides a string into UTF-16 code units, not characters. Most emoji and other characters outside the Basic Multilingual Plane are stored as two code units (a surrogate pair); splitting and reversing separates that pair, so the two halves end up out of order and no longer form a valid character.
Can I use string reversal to check for a palindrome?
Yes — normalize the string first (lowercase it, strip spaces and punctuation), then compare it to its reversed form. If they match, it's a palindrome; racecar and a normalized A man a plan a canal Panama both pass this check.
Does this tool send my text to a server?
No. The reversal runs client-side in your browser using Array.from(input).reverse().join('') — the text in the Source field is never sent anywhere.
Does reversing a string change its length?
No — reversing only reorders characters, it doesn't add or remove any, so the output always has the same character count as the input. Reversing the result a second time returns the original string.