Skip to main content
TextReverse

Reverse Lines

Flip the order of lines in a list, a log file or any multi-line block. The first line becomes the last and the text inside each line is left completely untouched.

This is the only reversal on the site that treats your text as records rather than characters, which makes it the right tool for chronological data — turning an oldest-first log into a newest-first one without a script.

Line 1 Line 2 Line 3Line 3 Line 2 Line 1

Want the words reversed too? Reverse word order

Try an example
0 characters0 words0 lines
Output
Your transformed text will appear here...
0 characters0 words0 lines
Ctrl + Enter Copy resultEsc Clear

Line Order Examples

Line reversal never touches the characters inside a line. These rows show what that means in practice, including the CRLF case.

InputOutputWhat it shows
Line 1 Line 2 Line 3Line 3 Line 2 Line 1The basic case: three lines, order flipped, contents identical.
apple banana cherrycherry banana appleAn alphabetical list becomes reverse alphabetical without sorting.
only lineonly lineSingle-line input is returned unchanged.
a bb aA blank line keeps its position relative to the lines around it.
2026-01-01 start 2026-06-01 middle 2026-07-01 end2026-07-01 end 2026-06-01 middle 2026-01-01 startOldest-first log becomes newest-first.
1. first 2. second 3. third3. third 2. second 1. firstNumbering does not renumber — the list reverses with its original labels.
a bb aCRLF is matched as one ending, so Windows line breaks stay where they were.
top middle bottom bottom middle topA trailing newline creates an empty final line, which becomes the first line.

How Line Reversal Works

Three lines of code, but the behaviour around line endings and blank lines is worth spelling out.

The text splits on any line ending

CRLF, a lone carriage return and a bare line feed are all recognised as one break. Every line becomes an array element, the array is reversed, and the original separators are put back where they were. Nothing inside a line is examined or modified.

Blank lines are lines

An empty string between two newlines is an array element like any other, so blank lines keep their relative position in the reversed output. Paragraph spacing therefore survives the reversal.

Windows line endings survive

CRLF is two characters, and a reverser that splits on \n alone strands the \r at the end of a different line. This one matches CRLF as a single ending and leaves the separators in place while the line contents move, so text pasted from a Windows editor comes back with its endings unchanged.

It reverses back exactly

Running the output through the tool again reproduces your original, because no content is changed and no line is added or removed.

Lines, Words or Characters

Applied to the same three-line block, the four reversals produce very different results.

Shared input: alpha one beta two gamma three

TransformationResultReach for it when
Reverse linesgamma three beta two alpha oneYou want the record order flipped, contents untouched.
Reverse wordsthree gamma two beta one alphaYou want every word reordered across the whole block.
Reverse each wordahpla eno ateb owt ammag eerhtYou want each word spelled backwards, layout kept.
Reverse everythingeerht ammag owt ateb eno ahplaYou want one continuous end-to-start reversal.

Line Reversal Edge Cases

These four cases account for nearly every surprise when reversing files rather than prose.

A trailing newline becomes a leading blank line

Text files conventionally end with a newline, which creates an empty final element. After reversal that empty line is first, so the output appears to start with a blank line. Delete the trailing newline first if that matters.

Numbered lists do not renumber

The tool moves lines, it does not interpret them. A list numbered 1, 2, 3 comes back as 3, 2, 1 with the original numbers attached — usually not what you want for a numbered list.

Wrapped text is not lines

A paragraph that wraps visually is one line as far as the tool is concerned. Only actual newline characters create lines, so soft-wrapped prose reverses as a single unit.

CSV headers move too

Reversing a CSV puts the header row at the bottom. Cut the header out first, reverse the body, then put the header back.

Working with Lists and Logs

Line reversal is the most "practical" tool on the site — most of its use is data handling rather than novelty.

Log files

Turning an oldest-first log into newest-first is the most common use. Paste the block, reverse, and read the most recent events at the top without piping through tac or Sort-Object.

Spreadsheet columns

Copy a column, reverse it here, paste it back to flip the row order without adding a helper column and a sort. Blank cells become blank lines and keep their positions.

Markdown and documents

Reversing a bulleted list works cleanly because bullet characters travel with their line. Numbered lists need renumbering afterwards.

Code and config files

Useful for reordering import blocks or environment files. Because contents are untouched, indentation is preserved exactly as it was.

Reasons to Reverse Line Order

Newest-first reading

Chronological exports almost always come oldest-first. One paste turns them into the order you actually want to read.

Reversing a ranked list

Turn a top-ten list into a countdown, or vice versa, without retyping or re-sorting.

Building test data

Reversed fixtures catch code that quietly assumes input arrives in a particular order.

Quick diffs by eye

Reversing both of two lists puts their tails side by side at the top, which sometimes makes a difference easier to spot.

Frequently Asked Questions

Related Text Tools

Browse all text tools →