Four pick modes, one N parameter
First (default): keeps items 0..N-1 in their original order. Random: Fisher-Yates shuffle then take first N - unseeded, so each run produces a different sample unless you copy the output. Longest / Shortest: sorts by `line.length` then takes N from the top.
If N is larger than the list, the entire list is emitted - there is no padding or error. N ≤ 0 produces an empty output.
Same op as Head of a list. The inverse framing (`keep the LAST N`) is Tail of a list, which shares the mode set.
How to use truncate a list
- 1Paste your list into the input panel
- 2Set Keep N (default 5)
- 3Pick mode: First (default), Random, Longest, or Shortest
- 4Output contains at most N items
- 5For the LAST N instead, use Tail of a list
Keyboard shortcuts
Drive ListShift without touching the mouse.
What this tool actually does
Bounded keep-N with four selection strategies.
First: order-preserving head slice
Takes items 0..N-1 in input order. Deterministic and fast.
Random: unseeded Fisher-Yates sample
Shuffles the list then takes the first N. No seed input - repeat runs yield different samples. Copy the output if you need it reproducibly.
Longest: N longest by character count
Sorts by line length descending, takes first N. Ties resolved by original order (stable sort). Useful for finding verbose items or longest URLs.
Shortest: N shortest by character count
Opposite of Longest. Handy for finding terse items or suspicious outliers (1-character entries, typos).
No padding if list is shorter than N
Output is `min(N, list.length)` items. An empty list stays empty. N ≤ 0 produces empty output.
Worked example
Default N=5, Pick=First. Keeps `apple` through `elderberry`, drops `fig` and `grape`.
apple banana cherry date elderberry fig grape
apple banana cherry date elderberry
Settings reference
How each option shapes the output using the sample above (7 items).
| Setting | What it does | Effect on the sample |
|---|---|---|
| Keep N: 5 (default), Pick: First (default) | First 5 items in order | `apple` / `banana` / `cherry` / `date` / `elderberry` |
| Pick: Random | 5 random items, different each run | Sample varies - e.g. `date, fig, apple, cherry, grape` |
| Pick: Longest | 5 longest by character length | `elderberry` (10), `banana` (6), `cherry` (6), `grape` (5), `apple` (5) |
| Pick: Shortest | 5 shortest by character length | `fig` (3), `date` (4), `apple` (5), `grape` (5), `cherry` (6) |
| Keep N: 100 (bigger than list) | Entire list emitted | All 7 items, no padding |