Skip to content

Reverse Line Order

Last line first, first line last.

Reversing line order flips a list end to end: the last line becomes the first, the first becomes the last, and everything in between mirrors around the middle. The content of each line is untouched — only their sequence changes.

The most common reason to need it is chronology. Logs, exports, and chat transcripts are frequently written oldest-first when you want newest-first, or the other way round. Changelogs have the same problem in reverse: they are usually maintained newest-first, but reading the history of a project makes more sense from the beginning.

It is also the quickest way to undo an unwanted sort. If a list was ordered Z to A and you wanted A to Z, reversing gets you there without re-sorting and without touching the entries themselves.

One property makes this safe to experiment with: reversing is its own undo. Run it twice and every line is back in its original position, with nothing inside it changed. The one thing that does not survive the round trip is Windows line endings, because the output always uses line feeds — the text is identical, the invisible break characters are the simpler form. If you are unsure whether a list is in the order you want, flipping it and flipping it back costs nothing.

Examples

Examples for Reverse Line Order: each row pairs an input with the output it produces.
What it handles Input Output
A short list one two three three two one
Line content is untouched a: 1 b: 2 b: 2 a: 1
Applying it twice restores the original three two one one two three

How it works

The text is split on line breaks, the resulting array is reversed, and the lines are joined back together with newline characters. Line endings are normalized to line feeds in the output so that text pasted from Windows, macOS, and Unix sources all behave the same way. Nothing inside a line is modified: spacing, punctuation, capitalization, and any trailing whitespace come through exactly as they went in. Applying the operation twice returns the original order of lines, which makes it safe to experiment with.

When people use it

  • Flipping a log file so the newest entries appear first.
  • Reading a changelog from the beginning of the project.
  • Reversing an export that came back in the wrong direction.
  • Undoing a sort without re-sorting the list.

Frequently asked questions

Does it reverse the characters in each line?
No. Only the order of the lines changes. The text inside each line stays exactly as it was.
What happens to blank lines?
They are treated as lines and move with everything else, so the shape of the list is preserved after flipping. One consequence worth knowing: a file that ends with a line break ends with an empty last line, and after reversing that empty line is at the top.
Is this the same as a reverse text generator?
No. A reverse text generator flips the characters, turning "hello" into "olleh". This tool reverses text lines: the order of the lines changes and the content of each line is left exactly as it was.
Will it change my line endings?
The output uses line feeds. If you pasted Windows-style endings, the result will use the simpler form, which every modern editor handles.