Reverse Line Order

Reverse the order of lines in any text. The last line becomes the first, the first becomes the last.

Example: Line one Line two Line threeLine 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.

When you reach for this

Most-recent-first log files

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.

Reverse-engineering tutorials

Step-by-step instructions sometimes need to be read in reverse to understand the end state and work backward to the prerequisites.

List sorting variations

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.

Reorder ranked lists

Top-10 lists ranked best-to-worst can be flipped to worst-to-best with one click for storytelling effect.

Subtitle / lyric work

Reverse-order lyric printing for backwards-reading effects, or reordering subtitle blocks while keeping each block intact.

What gets processed (and how)

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.

How to use it

  1. Paste or type your text into the input box.
  2. Ensure each line is separated by a newline (press Enter).
  3. Click the 'Reverse Line Order' button.
  4. Copy the reversed text from the output box.

Behavior on tricky inputs

Trailing newline
If the input ends with a newline, an empty line will appear at the top of the output because the last element becomes empty after splitting.
CRLF vs LF
The tool handles both line endings automatically, but the output uses the same line ending as the input for consistency.
Empty lines
Empty lines are preserved; they become empty strings in the array and will reverse accordingly.
Single line
If there is only one line, the output is identical to the input.

Workflow tips

  • Use to reverse a numbered list so that the last item becomes first without rewriting numbers.
  • Combine with 'Remove Duplicate Lines' to get unique lines in reverse order of first appearance.
  • If you have trailing newlines, consider trimming them first for predictable output.
  • For very large texts (100,000+ lines), the tool may be slower; split into chunks if needed.

vs other ways to do this

Several methods can reverse line order; here's how this tool compares to common alternatives.

This toolUnix `tac` commandExcel Sort
Line ending handlingAuto-detects CRLF and LFWorks only with LF unless convertedWorks with CRLF only; LF may cause issues
Preserves whitespaceKeeps all leading/trailing spacesPreserves whitespaceTrims leading/trailing spaces by default
Ease of useNo installation, browser-basedRequires Unix shell or WSLRequires Excel and copy-paste
Batch processingSingle text at a timeProcesses entire filesProcesses columns; reordering rows only with workarounds

Where this came from

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.

Common questions

What counts as a line break?
Any newline character (\n). Both Unix-style (LF) and Windows-style (CRLF) are recognised. Soft line breaks created by word-wrap in your editor don't count — only hard line breaks where you pressed Enter.
Does it preserve blank lines?
Yes. Blank lines (consecutive newlines) are preserved in their reversed positions, so paragraphs separated by blank lines stay structurally intact.
How is this different from sorting?
Reversing flips the existing order without changing it; sorting rearranges based on alphabetical or numeric value. If your input is "banana / apple / cherry" reversed gives "cherry / apple / banana"; sorted gives "apple / banana / cherry".
Can I reverse a CSV file by row?
Yes — paste your CSV into the tool. Each row (line) is reversed in order while staying intact. The header row will move to the bottom; if you want it at the top, paste body rows separately and add the header back manually.
Is the operation reversible?
Yes. Running it twice returns the original. Line-order reversal is an involution: reverse(reverse(x)) = x.

Embed our tools on your website

Free for any site. No signup. Iframe loads from our servers and stays up-to-date automatically.

📋 Embed the Word Counter

Copy this snippet (auto-resizes, Copy button works):

Live preview:

📋 Embed this Reverse Line Order

Copy this snippet (auto-resizes, Copy button works):

Live preview:

Want more options? All embeddable tools →