Extract a list fragment

Paste one item per line and get back the items between `From` (inclusive) and `To` (exclusive), using zero-based indices. Defaults slice `2..6` - items 3, 4, 5, 6 of the list. Optional Every-Nth stride. Same op as Slice a list and Extract a sublist by range.

Input
Ready
Output
Live

Array.slice semantics

Under the hood this is `Array.prototype.slice(from, to)` on your list's non-empty lines. `From` is inclusive, `To` is exclusive - the classic JavaScript / Python convention. Zero-based: `From = 0` means "start from the first item", `From = 2` means "start from the third item".

Leave `To` blank to slice to the end. Leave `From` blank or at `0` to start at the beginning. Negative indices are passed through to `slice` and count from the end (`From = -3` is "the last 3 items").

Every-Nth applies after the slice - set it to `2` and you get every other item from the sliced range, `3` gives every third, and so on. Default `1` keeps every item. Out-of-bound ranges return an empty result without error.

How to use extract a list fragment

  1. 1Paste one item per line into the input panel
  2. 2Set `From` (0-based, inclusive) - default `2`
  3. 3Set `To` (0-based, exclusive) - default `6`, blank means end
  4. 4Optionally set Every-Nth to stride through the sliced range
  5. 5Output updates live; out-of-bound indices return empty without error

Keyboard shortcuts

Drive ListShift without touching the mouse.

Shortcut Action
Ctrl ZUndo last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor
EscExit fullscreen
Ctrl KOpen the command palette to jump to any tool
Ctrl SSave current pipeline draft Plus
Ctrl PRun a saved pipeline Plus

What this tool actually does

Array.slice with an optional Every-Nth stride.

`From` inclusive, `To` exclusive

`From = 2, To = 6` gives indices 2, 3, 4, 5 (four items). The item at index 6 is not included - matches JavaScript / Python slice semantics.

Zero-based indexing

The first item is at index `0`, not `1`. `From = 1` starts at the *second* item. If you think 1-based, subtract one everywhere.

Negative indices count from end

`From = -3` starts at the third-from-last item. `To = -1` ends before the last item. Great for "last N items" or "all but the last few".

Blank To means end of list

Leave `To` empty (or unset) to slice from `From` through the last item. Default sample has `To = 6` so the result is finite, but most real uses leave To blank.

Every-Nth stride after the slice

Every-Nth filters the sliced range by index. `2` = every other item (indices 0, 2, 4, ...), `3` = every third, and so on. Applied *after* slicing, so the stride is relative to the slice output.

Worked example

Default `From = 2`, `To = 6`, step = 1. Items at indices 2, 3, 4, 5 are returned (cherry, date, fig, grape).

Input
apple
banana
cherry
date
fig
grape
Output
cherry
date
fig
grape

Settings reference

How each option shapes the output using the sample above.

Setting What it does Effect on the sample
`From: 2`, `To: 6` (defaults) Indices 2..5 inclusive (To is exclusive) `cherry`, `date`, `fig`, `grape`
`From: 0`, `To: 3` First three items `apple`, `banana`, `cherry`
`From: -3`, `To: blank` Last three items `date`, `fig`, `grape`
`From: 0`, `To: blank`, `Every-Nth: 2` Every other item, starting from index 0 `apple`, `cherry`, `fig`
`From: 10`, `To: blank` (out of bounds) No items to return Empty output (no error)

FAQ

Are indices zero-based or one-based?
Zero-based. The first item is at index `0`, the second at `1`, and so on. If you think in one-based numbering, subtract one when filling in From / To.
Does `To` include or exclude the item at that index?
Exclusive - the item at `To` is NOT included. `From = 2, To = 6` returns items at indices 2, 3, 4, 5 (four items). That matches JavaScript `Array.slice` and Python `list[from:to]`.
What happens if From > To?
Empty output. The slice is invalid, but no error is shown - the tool just returns nothing.
Can I use negative indices?
Yes. `From = -3` counts from the end (third-from-last). `To = -1` excludes the last item. Useful for tail-style slices without knowing the list length.
How does Every-Nth interact with the slice range?
It applies after the slice. `From = 0, To = 10, Every-Nth = 3` first slices to items 0..9, then keeps every third (indices 0, 3, 6, 9 of that slice). The stride is relative to the slice output, not the original list.