Set list length

Force a list to exactly `N` items. If your list is longer than `N`, the extra items are dropped from the end. If shorter, the tool pads the tail with your chosen string (default is an empty string, so padding appears as blank lines). Useful for aligning lists before a zip, batching into fixed-size rows, or padding sparse data to a grid.

Input
Ready
Output
Live

Truncate-or-pad to a fixed N

The op runs `items.slice(0, n)` to truncate, then appends the Pad with string until the length hits `n`. If your list has exactly `n` items, nothing changes. If more, the tail drops. If fewer, the tail grows with padding.

Pad with is literal text - default empty string produces blank padding lines. Set it to `-`, `N/A`, or a placeholder token to make the padded rows visually distinct. Every padded line is identical; this is not a serial-numbered filler.

Unlike Truncate (which only shortens) and Head (first-N selection), Set length always normalises to exactly N - padding up *or* trimming down as needed.

How to use set list length

  1. 1Paste your list into the input panel
  2. 2Set `Target length` to the exact number of items you want (default `10`)
  3. 3Set `Pad with` to the placeholder for short lists (default blank)
  4. 4Output always has exactly `N` items - truncated if long, padded if short
  5. 5For truncation-only behaviour, use Truncate a list

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

Truncate-or-pad to a fixed count. Two options.

Exact length output

The output is always exactly `N` items. Longer lists lose their tail; shorter lists gain padded rows until they hit `N`.

Any string as padding

Default Pad with is empty (blank lines). Use `-`, `N/A`, `--empty--`, or any other token to visually mark padded rows. The same string is used for every padded line.

Order preserved

When truncating, items at the tail are dropped (not from the head or middle). When padding, new lines are appended after your existing items, not interspersed.

Blank input + Pad set = all-padding output

If you paste nothing and set `N = 5` with `Pad with = -`, the output is five `-` lines. Useful for generating fixed-count filler.

Zero-or-negative N collapses to an empty list

`parseInt` on invalid values gives NaN which coerces to 0 in the slice - output is empty. Set a positive integer to get a meaningful result.

Worked example

Default `N = 10`, Pad = blank. 12-item input truncates to the first 10 items; no padding needed.

Input
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10
Item 11
Item 12
Output
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10

Settings reference

How each option shapes the output using the sample above (12-item input).

Setting What it does Effect on the sample
`N: 10`, Pad: blank (defaults) Truncates to first 10 items (no padding needed here) `Item 1`..`Item 10`
`N: 5`, Pad: blank Truncates to first 5 items `Item 1`..`Item 5`
`N: 15`, Pad: `-` 12 items + 3 padded rows of `-` `Item 1`..`Item 12`, then `-`, `-`, `-`
`N: 15`, Pad: blank 12 items + 3 blank padded rows `Item 1`..`Item 12`, then three blank lines
`N: 0` (or negative / non-numeric) Empty output (empty)

FAQ

What happens if my list is longer than N?
Items beyond index `N-1` are dropped. Truncation happens from the tail, not the head - `N = 5` keeps the first 5 items.
What happens if my list is shorter than N?
The tool pads the tail with the Pad with string until the list has exactly `N` items. Default padding is an empty string (blank lines).
How is this different from Truncate a list?
Truncate only shortens - it never pads. Set list length does both: it ALWAYS produces exactly `N` items, padding up when needed. Pick Truncate if you only want the first N; this tool if you need an exact count.
Can I pad with serial numbers (filler-1, filler-2, ...)?
Not directly - all padded rows use the same string. For serial padding, pad with a constant here, then chain Add counters or Add a prefix with Numbered style.
What if N is 0 or negative?
Output is empty. `parseInt` rejects non-numeric values and negatives coerce through the slice to an empty result.