Three buttons, three different reversals
Each button rewrites the text in the box immediately and there is no undo, so copy anything you want to keep first. Because every reversal is its own inverse, pressing the same button twice restores the original text exactly (except that Reverse line order rewrites line endings as plain line breaks).
| Button | What it does | Input | Output |
|---|---|---|---|
| Reverse characters | Reverses the whole text, line breaks included | Hello, World! | !dlroW ,olleH |
| Reverse words | Reverses the order of words on each line, keeping each word and its spacing intact | one two three | three two one |
| Reverse line order | Last line first, first line last; the lines themselves are untouched | line 1, line 2, line 3 | line 3, line 2, line 1 |
How it works under the hood
Character reversal splits the text into visible characters (grapheme clusters, using the browser's Intl.Segmenter) and reverses that list. This is better than reversing raw 16-bit units, which would tear emoji into broken halves, and better than reversing code points, which would separate a letter from its accent. In a browser without Intl.Segmenter it falls back to code points. Word reversal splits each line on whitespace but keeps the whitespace as separate items, so double spaces and tabs stay exactly where the gaps were, just mirrored. Because it works line by line, a multi-line text keeps its lines in the same order, and only the words inside each line flip. Reverse line order accepts Windows, Unix and old Mac line endings and writes plain line breaks, so no stray carriage return is left on a line.
Where reversal goes wrong
- Combining accents and emoji sequences are kept whole. A letter written as
eplus a combining acute accent, a thumbs-up with a skin tone and a family emoji built from several joined code points each count as one character, soéareverses toaéwith the accent still on the e. - Font support still matters. Reversal never splits a character, but an emoji your device cannot draw as one picture may look different in the reversed text than on a device that supports it.
- Right-to-left scripts. Arabic and Hebrew text is stored in reading order, so reversing characters produces the opposite of what you might expect visually.
- Reversed text is not "mirror" text. Letters are not flipped or substituted. For upside-down letters use the upside down text generator.
Typical jobs are palindrome checks (reverse and compare), flipping a chronological list so the newest item comes first, and quick puzzles. Once reversed, run the result through the word counter if you need to confirm that nothing was lost.