What this tool does
Reverse String flips your text backwards in one of three ways:
- Characters,
abc→cba. Every character is reversed, including spaces and punctuation. - Words,
hello world foo→foo world hello. Word order is reversed; the words themselves stay forwards. - Lines, reverses the order of lines (last line on top, first line on the bottom). Useful for log files where newest entries are typically at the bottom.
Pick a mode from the toolbar segmented control, paste your text, and the output updates on every keystroke after a short debounce.
Why three modes?
"Reverse the text" is ambiguous in real-world tasks, and getting the wrong meaning silently mangles your data. Three explicit modes make the intent clear:
- You want the palindrome check or the last-character-first read, that's character reversal.
- You want last-word-first for a poetic effect, or you're reordering tokens that happen to be space-separated, that's word reversal.
- You have a chronological list and want newest-first instead of oldest-first, that's line reversal.
Reaching for the right mode beats post-processing the wrong mode's output.
Character reversal handles emoji correctly
Naive character reversal in JavaScript using str.split('').reverse().join('') corrupts emoji and any character outside the Basic Multilingual Plane, because those code points are stored as surrogate pairs of two code units, and .split('') happily splits them. Reverse the halves and you get an invalid UTF-16 sequence.
This tool uses [...str] (the spread iterator), which iterates code points rather than code units. Emoji, mathematical symbols, and CJK extension characters round-trip correctly. A flag emoji like 🇺🇸 (which is itself two regional-indicator characters) does end up reversed letter-by-letter, but each component is preserved, not corrupted.
For full grapheme-cluster reversal (treating 🇺🇸 as one unit, treating é as one é), you'd need Intl.Segmenter. This tool does the simpler code-point reversal, which is correct for 99 % of real inputs and predictable for the rest.
Word reversal preserves whitespace
Word mode splits on whitespace runs including the runs themselves, reverses the resulting array, and rejoins. Concretely: hello world (three spaces) reverses to world hello, the triple space is preserved as one unit.
That matters when the text is column-aligned or contains intentional non-breaking spaces. A naive .split(' ') would normalise the spacing on every reverse, gradually destroying alignment.
When to reach for this tool
- Coding interview practice, reverse-a-string is a classic warm-up. Use this to verify your hand-written solution against a known-good output.
- Reverse-chronological log inspection, paste a log file, switch to Lines mode, and read newest-first.
- Sorting in reverse without re-sorting, already-sorted output, line mode, done. Faster than re-sorting with the opposite comparator when the list is large.
- Palindrome verification, reverse characters, compare to original. (Strip whitespace and lowercase first if you're being strict about it.)
- Creative writing, backward-text effects in poetry, reversed signage mockups, "reading from the back" exercises in language learning.
Common gotchas
- Reversing reverses again gives you the original. All three modes are involutions, apply twice and you're back where you started.
- Mode change re-runs immediately. If you reverse, then switch mode, the output is computed from the input, not the previously reversed output. To chain reversals (e.g. reverse lines then reverse characters), copy the output back into the input.
- Trailing newlines. Line mode preserves a trailing newline if your input had one, the empty final "line" becomes the new first line. Trim before reversing if that bothers you.
- Bidirectional text. Reversing Arabic or Hebrew character-by-character produces a string that displays unexpectedly because of the Unicode bidirectional algorithm. The bytes are correctly reversed; the display is what's lying.
Privacy
Your text is reversed entirely in your browser using native JavaScript string operations. Nothing is uploaded to any server. Recent inputs live in your browser's local storage and can be cleared from the "Recent" card.