# Reverse Lines

> Reverses the order of the lines so the last line comes first

Version: 1.0.0 · By Deck

- Install in Deck: deck://install-plugin?id=reverse-lines&url=https%3A%2F%2Fgithub.com%2Fyuzeguitarist%2Fdeck-plugins%2Freleases%2Fdownload%2Fplugins%2Freverse-lines-1.0.0.zip
- Download .zip: https://github.com/yuzeguitarist/deck-plugins/releases/download/plugins/reverse-lines-1.0.0.zip
- View on GitHub: https://github.com/yuzeguitarist/deck-plugins/tree/main/plugins/reverse-lines

Or install with Terminal: 

```sh
mkdir -p ~/.deck/scripts/reverse-lines && curl -fsSL https://github.com/yuzeguitarist/deck-plugins/releases/download/plugins/reverse-lines-1.0.0.zip | tar -xf - -C ~/.deck/scripts/reverse-lines
```

## Script

```js
// Reverses the order of the lines, so the last line comes first.
function transform(input) {
  const text = String(input ?? "").replace(/\r\n?/g, "\n");
  if (text === "") return "";
  const end = text.endsWith("\n") ? "\n" : "";
  return (end ? text.slice(0, -1) : text).split("\n").reverse().join("\n") + end;
}
```

---

- HTML: https://deckclip.app/plugins/reverse-lines
- 中文: https://deckclip.app/zh-cn/plugins/reverse-lines.md

© 2026 Yuze Pan
