Reverse line order
The lines “first line”, “second line” and “third line” come back as “third line”, “second line”, “first line”: the order flips, while each line stays readable left to right. Blank lines and indentation move along. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Text
- first line second line third line
- Result
- third line second line first line
- Line count
- 3
When a log, list, or paste arrives with the newest entry at the bottom and you need the opposite, reversing line order is faster than rewriting the file by hand. This capability takes multi-line text, keeps every line’s content intact—including blank lines and surrounding spaces—and returns those lines from last to first. It accepts Unix LF, Windows CRLF, and classic Mac CR endings, normalizes the output to LF, and restores a trailing newline when the input had one.
What reverse line order actually changes
Reversing lines is not the same as reversing a string character by character. Each line stays readable left to right; only the sequence of lines is flipped so the former last line becomes the first. That distinction matters for logs, changelists, CSV-like row dumps without a header, poetry stanzas, and any paste where people think in rows rather than bytes.
Blank lines count as lines: if you intentionally left a gap between blocks, that gap moves with the reverse and is not stripped. Leading and trailing spaces inside a line are preserved so indentation and padded columns survive. The tool does not sort alphabetically, deduplicate, trim, or rewrap text; it only reorders.
Because the work is pure local parse logic, the same input always produces the same output, with no model, network call, or locale table involved.
Line endings, trailing newlines, and empty input
Real-world text rarely uses a single newline style. Editors, shell redirects, and email clients mix LF, CRLF, and occasionally bare CR. On input this capability splits on any of those sequences so mixed dumps still reverse correctly.
The rejoined result uses LF between lines for a stable, portable representation across platforms. If the original text ended with a newline, the result ends with a newline as well; if it did not, neither does the result—so tools that treat a final newline as a file-shape detail keep that shape. Extremely large pastes are bounded by a character limit so memory use stays predictable on the edge worker and in the browser.
Where reverse line order fits in real workflows
Support engineers reverse log tails so the newest stack frame sits at the top before pasting into a ticket. Writers reverse draft outlines when a brainstorm was captured bottom-up and the published structure should read top-down. Data practitioners flip a small multi-line export before a tool that assumes newest-first rows.
The response reports the reversed text, how many lines were processed, and whether a trailing newline was restored—enough metadata to assert behavior in automated checks without re-parsing the body.
What you can do with it
Newest-first log paste
Flip a chronological log so the latest events appear first before sharing a support snippet or incident note.
Outline and list reorder
Turn a bottom-up brainstorm list into a top-down outline without rewriting each bullet by hand.
FAQ
Does it reverse characters inside each line?
No. Only the order of lines changes. Text within a line stays left-to-right exactly as submitted.
What happens with blank lines?
Blank lines are real lines and move with the reverse. They are not stripped or collapsed.
Which line endings are accepted?
LF, CRLF, and CR on input. Output joins lines with LF and restores a trailing newline only if the input had one.
What if the text is empty?
Missing or non-string text also fails. Failed validation is not charged.
How do I put the newest log entries at the top?
Paste the log as it is, with the oldest entries first. The last line becomes the first, so the most recent event sits at the top, ready to paste into a ticket, and every line stays intact.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/str/reverse-lines \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"first line\nsecond line\nthird line"}'const res = await fetch("https://api.kit.forhosting.com/str/reverse-lines", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"text": "first line\nsecond line\nthird line"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/str/reverse-lines",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"text": "first line\nsecond line\nthird line"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/str/reverse-lines", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"text":"first line\\nsecond line\\nthird line"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"text":"first line\nsecond line\nthird line"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/str/reverse-lines", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"text": "first line\nsecond line\nthird line"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "str.reverse_lines",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Empty input is rejected with invalid_input so pipelines fail loudly instead of inventing an empty success. The same deterministic path powers the free browser form and the API at $0.002 per successful request.
Line endings, trailing newlines, and empty input
An empty string, missing text field, or non-string text fails immediately with invalid_input and a clear message. That rule prevents silent no-ops in jobs that accidentally pass blank bodies after a failed download or an empty template expansion. Use the free form for one-off flips; wire the API when a pipeline needs the same contract every time.
Where reverse line order fits in real workflows
Because successful API calls cost only $0.002 and failed validation is not billed, you can probe empty or malformed payloads without draining prepaid balance. Drop the call into a shell script, a CI step, or a help-desk macro: anywhere people currently open an editor and drag the last line to the top. Tier-A parse work keeps latency low and removes the need for a container or language model on every request.
Integration use cases
Test fixture generation
Produce deterministic reversed multi-line fixtures for unit tests that assert row order after a transform.
Technical questions
How much does the API cost?
$0.002 per successful request. The browser tool is free. Invalid input is not charged.