ComfyUI Node

Slice List

Python slicing, exposed as a node — start, end, done

By kenjiqq·Created 3 years ago·Updated about a year ago· 76
Slice List
  • list
  • LIST
start0
end1

Slice List is the trim tool of kenjiqq's pack: give it a LIST and two integers, get back a sub-list. It's the kind of node that feels pointless until the day you need it, and then it's exactly the thing you needed - no Python scripting, no workarounds, just list[start:end] exposed as a node.

It exists because the pack's whole job is handing lists around - to XY Grid Helper, to Any List Iterator, to axis packing - and real lists need pruning. You don't want to regenerate a 200-line prompt file just because you want to test rows 3–10.

How it works

  • list - the input LIST.
  • start - an INT, default 0. Where the slice begins.
  • end - an INT, default 1. Where the slice stops.
  • LIST - the output, list[start:end].

The behavior is exactly Python slicing, which comes with two rules that surprise people:

  1. end is exclusive. A slice of 0 to 10 gives you 10 items (indices 0–9), not 11. Off-by-one confusion here is the classic bug.
  2. Negative indices work. start = -3 with end = 0 grabs the last three items. And out-of-range values don't error - Python just clamps to the edges, so end = 9999 on a short list silently gives you everything.

Where you'll actually use it

  • Splitting a big grid sweep. Have 50 prompts in a file but only want to run 5? Slice the LIST feeding row_list and queue a 5-row grid instead of re-editing the file.
  • Batching. With the pack's page_size on XY Grid Helper already handling grid splitting, Slice List is more useful when you're feeding Any List Iterator - slice the list to whatever window you want to step through.
  • Quick subsets. "Test every other value" is two slices and a compare, not an edit.

The honest version

This is a utility node, and it has no hidden depths - which is its charm. There's no state, no reset button, nothing to forget. If you know how Python slicing works, you know this node; if you don't, the two rules above are the whole manual.

Installing it

Part of qq-nodes-comfyui, no pip requirements:

cd ComfyUI/custom_nodes
git clone https://github.com/kenjiqq/qq-nodes-comfyui

Restart, or install qq-nodes-comfyui via ComfyUI Manager. You'll find it under QQNodes/List, right next to Any List and Any List Iterator - the family resemblance is clear.

CategoryQQNodes/List

Inputs (3)

NameTypeDefaultDescription
listLIST
startINT0
endINT1

Outputs (1)

NameTypeDescription
LISTLIST