Reading a forty-thousand-line log from the top
A build fails on line 39,812 of a log file. You open it, jump to the end, and now you are reading upward, which the eye resists after about twenty lines. Pasting the file in and reversing the lines puts the crash at the top and the build start at the bottom.
That is one of three jobs this tool does, and the one people discover last. The other two, reversing characters and reversing words, look like party tricks until you meet the specific problem each one solves.
Three modes, three different jobs
| Mode | What it operates on | What it is genuinely for |
|---|---|---|
| Characters | Every visible character, right to left | Palindromes, mirror writing, spotting a stray character at the end of a string |
| Words | Whitespace-separated tokens | Building "backwards sentence" demos, checking that a phrase survives reordering |
| Lines | Whole lines, in file order | Reading logs newest-first, working with a list whose last item matters most |
The three are not variations on one operation. Character mode keeps the line-break characters but mirrors them along with everything else, so a break can end up somewhere new; word mode deletes newlines entirely; and line mode never touches what is inside a line. Pick the wrong one and the output looks deliberate while being wrong.
Character mode counts graphemes, not code units
Most quick scripts that reverse a string do it by index, swapping position one with position last. That breaks the moment the text contains a character built from more than one piece, and modern text is full of them.
This tool segments the text into grapheme clusters first, where a cluster is what a reader perceives as one character, and reverses those units. The pieces stay together:
- An emoji with a skin tone modifier reverses as one unit, not as a face followed by a detached tone.
- A flag, two regional indicator letters joined by convention, comes back intact.
- A family emoji built from several people joined by invisible characters survives as one glyph.
- An accented letter built from a base letter plus a combining mark keeps the mark attached.
The honest caveat is that a grapheme cluster is a rendering convention, not a fact about meaning. Reversing Arabic or Hebrew cluster by cluster will not produce intelligible text, because those scripts already run right to left and each letter has context-dependent forms. Reversal is a string operation, not a language operation.
What character mode still moves
Grapheme safety does not mean character mode is tidy. It reverses everything, including the characters that are not letters.
Line breaks move. Feed in two lines and the break travels with the text, so the content of line one appears on line two and vice versa. Character mode cannot reverse each line internally in one pass.
Trailing whitespace becomes leading whitespace. A string ending in two spaces comes back starting with two spaces. That is useful as a diagnostic: if a value looks correct but fails a comparison, reversing it puts the suspect character at the front, often faster than reaching for a text cleaner.
Punctuation flips sides along with everything else, so a sentence ending in a period comes back starting with one.
Word and line mode, and the damage they do quietly
Word mode splits on whitespace and rejoins with single spaces. That one sentence explains both its use and its cost: the split is greedy, so a run of spaces or a newline is just another separator. A three-paragraph paste comes back as one continuous line, and you cannot undo that by reversing again, because the original whitespace is gone.
The more interesting defect is that word mode does not treat punctuation as a word. "Hello, world." reverses to "world. Hello," with the period and comma attached to whatever word they were touching. The words are in the right order and the sentence is unreadable.
Line mode is the inverse: it reverses the order of the lines and leaves every character inside them exactly where it was. Indentation, code syntax, links, and trailing punctuation all survive, which is why this is the mode for logs and lists.
Two small behaviours are worth knowing before using it on a file. Windows line endings are normalised to Unix ones, so a file that arrived with carriage returns leaves without them. And a file that ends with a newline reverses to one that begins with a blank line, because the empty string after the final line is itself a line. Pasting a log and seeing a blank first row is this, not a bug.
What reversal is for, and what it is not
Genuine uses, in rough order of frequency:
Palindrome checking. Reversing a candidate and comparing it to the original is the fastest confirmation, and character mode handles emoji and accented letters that a naive check mangles.
Spotting an invisible stray character. Reversal surfaces trailing characters at the front, useful when a value looks correct but fails a comparison.
Puzzle and code work. Reversal appears constantly in puzzle construction and in interview questions about strings.
Reading logs newest-first. The use from the opening, and the one that saves the most time in practice.
The uses it does not have matter just as much. Reversal is not encryption, because it is deterministic and needs no key. It is also the wrong tool for putting a list in order: sorting lines has six orderings and a numeric mode that reversal cannot imitate.
Frequently Asked Questions
Can I use reversed text to hide a message from someone?
No. Reversal is deterministic and needs no key, so anyone who recognises what they are looking at can undo it in one step. It stops a casual glance at best.
Why did my emoji stay intact when I reversed the characters?
Because the tool reverses grapheme clusters rather than individual characters. An emoji with a modifier, a flag, or a family sequence is treated as one unit, so its pieces stay in the intended order even though the units around them swap.
Why did word mode collapse my paragraph into one line?
Word mode splits on every run of whitespace, and a newline is whitespace, so paragraph breaks are consumed and replaced with a single space. To reverse word order without losing line structure, reverse each line separately.
Why does my reversed file start with a blank line?
Because the original ended with a newline, which creates an empty line after the last one. Reversing puts that empty line first. Delete it, or strip the trailing newline before pasting.
Is reversing lines the same as sorting them?
No. Reversing flips the existing order, so the result depends entirely on how the input was ordered. Sorting imposes a new order based on the values themselves. If the list was not already in a meaningful sequence, reversing it produces nothing useful.
Does character mode handle accented letters correctly?
Yes, including accents stored as a separate combining mark. The mark travels with its base letter, so élan reverses to nalé with the accent still sitting on the é.
Ask which mode before you ask for the result
The tool is trivial to run and easy to run wrongly, so make the choice explicit: do you want the order of items changed, or the contents of each item changed? Line mode answers the first and leaves your data intact. The other two rewrite whatever they touch.