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.

Frequently asked

What's the difference between the three reverse modes?

Characters reverses every code point: 'abc' becomes 'cba'. Words reverses the order of whitespace-separated tokens but keeps each token forwards: 'hello world' becomes 'world hello'. Lines reverses the order of lines, leaving each line's contents untouched — last line becomes first, first becomes last.

Does character reversal break emoji?

No. The tool uses the spread iterator ([...str]) which iterates Unicode code points rather than UTF-16 code units. Emoji, mathematical symbols, and CJK extension characters round-trip correctly. (Compound graphemes like flag emoji do reverse component-by-component, but each component remains valid.)

If I reverse twice do I get the original back?

Yes. All three modes are involutions — applying the same mode twice returns the original input exactly. Useful as a sanity check: if double-reversing changes anything, something else has corrupted the string in between.

Can I reverse lines and then reverse characters in one pass?

Not in one pass — switching mode re-runs against the original input, not the previous output. To chain reversals, copy the first output back into the input field, then switch mode and re-run. Two passes total.

Why does word reversal preserve multiple spaces?

The splitter keeps the whitespace runs as their own units in the array, reverses the whole array, and rejoins. That preserves intentional spacing — important for column-aligned text or non-breaking spaces. A naive split-on-space would collapse 'a b' to 'a b' on every reverse.

How do I check if my input is a palindrome?

Reverse in Characters mode and compare to the input. For a 'is this a palindrome ignoring spaces and case' check, lowercase and strip whitespace first (use Case Converter and a quick find-and-replace), then reverse and compare.

Why does my Arabic / Hebrew text look weird after reversing?

Reversal at the byte level is correct, but right-to-left scripts trigger the Unicode bidirectional algorithm in your browser, which can re-order how the reversed string is displayed. The data is fine; the rendering is following BiDi rules. Paste it into a code editor with BiDi off to see the raw reversed sequence.

Is my text sent anywhere?

No. Reversal happens entirely in your browser via native JavaScript string methods — no network requests, no logging of content. Recent inputs are saved only to localStorage so you can replay them, and you can clear them from the Recent card.