list_ListSlice
Python-style list slicing for any ComfyUI data type
- ANY
- data
If you've ever written my_list[2:-1] in Python and wished ComfyUI had the same shorthand for a batch or list running through your graph, list_ListSlice is that shorthand as a node. It's small, generic, and works on basically anything.
What it does
Part of cardenluo's ComfyUI-Apt_Preset, this node lives in the pack's data/list utility group and does exactly one thing: slice a list. The input type is * - a wildcard - so it accepts any list-typed connection ComfyUI hands it: images, floats, strings, latents, whatever. start and end behave like Python slice indices, including negative-index support (the default end is -1, meaning "up to but not including the last item," same as Python's list[start:-1]). Since start and end both accept enormous negative numbers, you have the full range of Python slicing tricks available - start=-5 for "last five items," end=0 combined with a negative start for a suffix, and so on.
Inputs and outputs
ANY- the list to slice (wildcard type*).start- slice start index, default 0.end- slice end index, default -1.
Output is data, also typed * and marked as a list - so downstream nodes still see a list, just a shorter one.
The thing to internalize if you don't already think in Python slices: end is exclusive. start=0, end=3 gives you items 0, 1, and 2 - three items, not four. And negative indices count from the back, so start=-3, end=-1 grabs the third-, second-, and last-but-one items - genuinely useful for "give me everything except the very last frame" type trims.
Where this fits
This is the node for trimming a batch down mid-pipeline - dropping a warmup frame from a video generation, taking only the first N results from an oversized batch before an expensive downstream step, or grabbing a tail slice for a "last few frames" preview. It pairs naturally with list_MergeList and list_num_range, this pack's other generic list tools: generate or merge a list, slice it to the range you actually need, then feed it onward.
Installing it
Through ComfyUI Manager: search ComfyUI-Apt_Preset. Manual install:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
Run install.bat on Windows (or install requirements.txt yourself), restart ComfyUI. list_ListSlice needs no external models or extra dependencies - it's pure Python list indexing under the hood.
Troubleshooting
As with every node in this pack, if it doesn't show up in the node search at all, check the ComfyUI console at startup for an import error first - ComfyUI-Apt_Preset is a large multi-dependency pack, and there's a documented case of it failing to import entirely for one user, unrelated to this specific node.
The failure mode that's actually about this node is an out-of-range or empty result: if start is larger than your list's length, or if start/end end up describing an empty range (say start=5, end=2), you'll get an empty list out, which will usually surface as a confusing error several nodes downstream rather than here. If something later in your graph complains about receiving zero images or zero items, trace back to check whether this node's slice actually produced anything - Python slicing never raises on an out-of-range index, it just silently returns less than you expected.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| ANY | * | — | |
| start | INT | 0 | — |
| end | INT | -1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| data | * | — |