Reverse line order

Reverse line order flips a block of text top to bottom, so the last line becomes the first and the first becomes the last. The characters inside each line are untouched; only the sequence of lines changes. A Drop Blank toggle removes empty lines before the flip so they do not land at the top. The transform runs in your browser. To reverse the characters within text instead, see reverse text; to reorder lines by content, see sort lines alphabetically.

Input
Line 1:1 LF
Result Reverse Line Order
0 lines 0 chars

How line reversal works

The input is split on \n or \r\n into an array of lines. That array is reversed, then rejoined with \n. Nothing inside a line is altered: words, spacing, capitalisation, and punctuation on each line are carried over exactly, only their top-to-bottom position changes.

This is different from reversing characters. Reversing characters turns abc into cba; this tool keeps each line readable and just plays the lines back in the opposite order. It is the quick way to turn an oldest-first log into newest-first, or to flip a ranked list end to end.

The optional Drop Blank toggle filters out lines that are empty or contain only whitespace before the reversal. With it off, a trailing newline in the input becomes a leading blank line in the output, which is expected but sometimes not what you want. Turn it on to keep the output tight.

How to use reverse line order

  1. 1Paste or type your lines into the input panel on the left.
  2. 2Read the reversed order in the output panel on the right.
  3. 3Turn on Drop Blank if empty lines should be removed before flipping.
  4. 4Copy the result with the Copy button, or download it as a text file.
  5. 5Run the tool again on the output to restore the original order.

Keyboard shortcuts

Drive TextResult without touching the mouse.

Shortcut Action
Ctrl FOpen the find & replace panel inside the input Plus
Ctrl ZUndo the last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor Plus
EscClose find & replace, or exit fullscreen
Ctrl KOpen the command palette to jump to any tool Plus
Ctrl SSave current workflow draft Plus
Ctrl PRun a saved workflow Plus

What this tool actually does

Reverses line order, not characters

The last line moves to the top and the first line moves to the bottom. Each line keeps its exact content: this is a reordering of whole lines, not a character reversal. Applying the tool twice returns the original text.

Handles both line endings

Input is split on Unix \n and Windows \r\n line endings, so text pasted from any platform reverses correctly. Output is joined with \n.

Optional blank-line drop

With Drop Blank on, lines that are empty or whitespace-only are removed before the flip, so they do not float to the top of the result. With it off, every line including blanks is preserved and reversed.

Order-only, content-safe

No trimming, case changes, or deduping happen. A line that appears twice appears twice in the output. To also drop repeats, run remove duplicate lines first.

Linear single pass

Splitting, reversing, and joining each run once over the input, so even a large list flips in one pass. It recomputes on every keystroke in your browser, with nothing uploaded.

Worked example

The five lines are played back bottom to top. Each line keeps its own text; only the order changes.

Input
one
two
three
four
five
Output
five
four
three
two
one

Settings reference

Setting or behaviour Effect on output
Line order Reversed: the last input line becomes the first output line.
Line content Untouched. Each line keeps its exact characters and spacing.
Drop Blank (default off) When on, empty and whitespace-only lines are removed before reversing.
Line endings Input split on \n or \r\n; output joined with \n.
Running twice Restores the original order, since reversal is its own inverse.

FAQ

Does this reverse the letters in each line too?
No. Only the order of the lines changes; each line keeps its exact text. To reverse the characters inside text, use reverse text, which turns abc into cba.
How do I get back to the original order?
Run the tool again on its own output. Reversing a reversed list restores the starting order, because flipping twice cancels out.
What happens to blank lines?
By default they are kept and reversed along with everything else, so a trailing blank line becomes a leading one. Turn Drop Blank on to remove empty and whitespace-only lines before the flip.
Is this the same as sorting in reverse?
No. Sorting reorders lines by their content, alphabetically or numerically. This tool ignores content and simply flips the existing order. For content-based ordering, see sort lines alphabetically, which has an ascending or descending option.
Will duplicate lines be removed?
No. Reversing is order-only, so any repeated line stays in the output. To drop repeats, run remove duplicate lines before or after reversing.