Reverse Line Order
Reverse the order of lines in any text. The last line becomes the first, the first becomes the last.
Line one
Line two
Line three → Line three
Line two
Line one
Reverse the order of lines in any text. The last line becomes the first, the first becomes the last.
Line one
Line two
Line three → Line three
Line two
Line one
Reversing line order is the most common form of text reversal designers and developers actually use. Unlike character reversal (which produces unreadable output) or word reversal (which scrambles syntax), line-order reversal preserves each line completely while only flipping the sequence.
This tool accepts any text with multiple lines — code, lists, log files, transcripts, song lyrics — and returns the same content with line order completely flipped.
Many CLI tools append to logs chronologically (oldest first). Reversing line order shows the most recent events at the top, matching the way humans scan information.
Step-by-step instructions sometimes need to be read in reverse to understand the end state and work backward to the prerequisites.
If your list is alphabetised A→Z and you need Z→A, line-order reversal is the fastest path — assuming each item is a single line.
Top-10 lists ranked best-to-worst can be flipped to worst-to-best with one click for storytelling effect.
Reverse-order lyric printing for backwards-reading effects, or reordering subtitle blocks while keeping each block intact.
The tool splits input text into an array using newline characters as delimiters, supporting both LF (\n) and CRLF (\r\n) line endings. It then reverses the order of the array elements and joins them back with the line separator detected from the input (defaulting to \n if no CRLF is present). The reversal preserves the exact content of each line, including leading/trailing whitespace. No trimming or normalization is applied. The algorithm runs in O(n) time where n is the number of lines.
Several methods can reverse line order; here's how this tool compares to common alternatives.
| This tool | Unix `tac` command | Excel Sort | |
|---|---|---|---|
| Line ending handling | Auto-detects CRLF and LF | Works only with LF unless converted | Works with CRLF only; LF may cause issues |
| Preserves whitespace | Keeps all leading/trailing spaces | Preserves whitespace | Trims leading/trailing spaces by default |
| Ease of use | No installation, browser-based | Requires Unix shell or WSL | Requires Excel and copy-paste |
| Batch processing | Single text at a time | Processes entire files | Processes columns; reordering rows only with workarounds |
Reversing line order is a classic text processing operation dating back to early Unix systems. The command tac (the reverse of cat) was introduced in AT&T Unix around the 1970s as part of the GNU coreutils. It provides a simple way to reverse the order of lines in a file. This tool brings that same functionality to the browser, eliminating the need for command-line access.
reverse(reverse(x)) = x.