A simple line slicer with one-based, inclusive bounds
From is the first line kept, To is the last line kept. Both are one-based to match the way humans count lines (line 1 is the first line, not line 0). The implementation converts to JavaScript zero-based slicing under the hood: lines.slice(from - 1, to) against the array produced by splitting the input on \r?\n.
If To is past the actual line count the slice stops at the last available line. If From is greater than To the result is empty. Both fields are bounded 1 through 100,000 by the registry, which covers very large pasted blocks without stalling the browser.
Need a non-contiguous selection? Pull each range separately and concatenate, or use regex replace with gm flags to drop unwanted lines. To slice each line by character index inside a larger block, use slice text.
How to use extract a contiguous range of lines
- 1Paste your text into the input panel on the left.
- 2Set From to the first line number you want to keep (one-based).
- 3Set To to the last line number you want to keep (inclusive).
- 4Read the extracted block on the right.
- 5Click Copy or Download in the output header.
Keyboard shortcuts
Drive TextResult without touching the mouse.
| Shortcut | Action |
|---|---|
| Ctrl F | Open the find & replace panel inside the input Plus |
| Ctrl Z | Undo the last input change |
| Ctrl Shift Z | Redo |
| Ctrl Shift Enter | Toggle fullscreen focus on the editor Plus |
| Esc | Close find & replace, or exit fullscreen |
| Ctrl K | Open the command palette to jump to any tool Plus |
| Ctrl S | Save current workflow draft Plus |
| Ctrl P | Run a saved workflow Plus |
What this tool actually does
One-based, inclusive on both ends
From = 1 means the first line. To = 5 keeps line 5. So From = 2, To = 5 returns four lines: 2, 3, 4, 5.
To beyond the file stops at the file
If the input has 10 lines and you set To = 50, the slice stops at line 10. No padding, no error.
From > To returns empty
If you set From later than To the result is the empty string. Useful when the inputs are bound to live form fields.
Both bounds capped at 100,000
The registry sets min: 1 and max: 100000 for both fields. Very large blocks (logs, dumps) work without browser strain.
Output is rejoined with LF
The kept lines are joined with \n regardless of whether the input used CRLF. The trailing newline is dropped because the slice does not include the line terminator after the last kept line.
Worked example
From 2, To 4. Lines 2 through 4 are returned; lines 1, 5, and 6 are dropped.
1: alpha 2: bravo 3: charlie 4: delta 5: echo 6: foxtrot
2: bravo 3: charlie 4: delta
Settings reference
| Behaviour | Effect on output |
|---|---|
| From (1-100000) | First line kept (one-based, inclusive). |
| To (1-100000) | Last line kept (one-based, inclusive). |
| To past the file length | Slice stops at the last available line. |
| From > To | Returns an empty string. |
| From = To | Returns exactly one line. |
| Line endings | CRLF input becomes LF output (split on \r?\n, join on \n). |