---
title: "Reverse Lines action for ActionClip"
canonical_url: "https://actionclip.app/actions/reverse-lines"
document_type: "standalone_action"
official: true
action_count: 1
catalog_schema_version: 1
catalog_revision: "2026-08-21.1"
catalog_published_at: "2026-08-20T18:50:00Z"
---

# Reverse Lines action for ActionClip

Reverse the order of selected lines.

## What it does

Reverses every line, including blank ones, normalizes line endings, and preserves whether the selection ended with a line break.

## Action details

| Field | Value |
| --- | --- |
| Category | Text Editing & Formatting |
| Action type | JavaScript |
| Result | Replace or copy text |
| Internet | Not required |

## Action and outcome

| Action | Outcome |
| --- | --- |
| **Reverse Lines** — Selected text: first second third | third second first |

## How to reverse the order of selected lines with ActionClip

1. Select the text you want to use.
2. Choose **Reverse Lines** from ActionClip.
3. Review the result, then replace the selection or copy the new text.

## Requirements

No setup required.

## Privacy

Runs locally in ActionClip’s JavaScript sandbox. Selected text does not leave your Mac.

## Action configuration

````javascript
function run(selected_text) {
  const normalized = selected_text.replace(/\r\n?|\n/g, "\n");
  const hadTrailingNewline = normalized.endsWith("\n");
  const lines = normalized.split("\n");
  if (hadTrailingNewline) lines.pop();
  return lines.reverse().join("\n") + (hadTrailingNewline ? "\n" : "");
}
````

## Links

- [HTML listing](https://actionclip.app/actions/reverse-lines)
- [Download action definition](https://actionclip.app/actions/reverse-lines.actionclip)
- [Browse Text Editing & Formatting actions](https://actionclip.app/marketplace#marketplace-textTools)
- [All Marketplace listings](https://actionclip.app/marketplace)
