List Item Selector
Slice, wildcard, and grab from any list in ComfyUI
- list_input
- any
- string
- length
ListItemExtract grabs one thing. Its bigger sibling ListItemSelector grabs many - by single index, by slice, or by wildcard pattern - and hands you the result in three different flavors. If you've got a list of prompts, tags, filenames, or seeds and you need "items 1, 3, and 5" or "everything matching *night*", this is the node.
It ships in drmbt/comfyui-dreambait-nodes, and it's one of the genuinely useful ones in that pack. Where ListItemExtract only accepts strings, this one takes any_typ - so a real Python list or tuple from any node that outputs one works, as does a string form.
The inputs that matter
list_input(any) - a real list/tuple, or a string representation of one. A string that starts with[and ends with]gets parsed as a Python literal; anything else gets split on commas and whitespace.item_indices(STRING) - the interesting one. Comma- or space-separated tokens, and each token can be:0- a single index. Negatives work, so-1is the last item.1:5or1:8:2- Python slice notation (start:end:step).cat*- a wildcard, matched case-insensitively against the items.
debug(BOOLEAN, default true) - prints a runningDEBUG:log to the console. Flip it off once you've confirmed it works.
The outputs
Three wires come out:
any- the selected item(s). One item → the item itself; several → a list.string- everything joined into a single text string.length(INT) - how many items got selected.
The gotchas
- The string output joins with spaces, not commas. For text workflows feeding back into a prompt, that's usually exactly what you want. If you needed commas, you'll notice.
- Debug is on by default and it's chatty. Expect a wall of
DEBUG:lines on your first run. It's the author's own doing and it's genuinely useful for debugging a wildcard that matches nothing - just turn it off after. - It uses
eval()on bracketed strings, not the saferast.literal_eval. For your own data, fine. For untrusted data, keep it away from the square brackets. - An empty selection doesn't error. You get empty strings and
length0, which can silently feed an empty prompt if you're not watching the output.
Install
Standard custom-node install:
cd ComfyUI/custom_nodes
git clone https://github.com/drmbt/comfyui-dreambait-nodes
Restart ComfyUI after cloning, or search comfyui-dreambait-nodes in ComfyUI Manager and let it install plus resolve dependencies. The pack's requirements.txt is heavy - transformers, torchaudio, librosa, bitsandbytes, moviepy and more - so the first install is the slow part, and it's the same regardless of which node in the pack you actually wanted.
The takeaway: this is the node you reach for when "grab a few things from a list" turns into a mini query language. Slices and wildcards cover most real use cases without you writing a single Regex node.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| list_input | * | Input list or string representation of a list | |
| item_indices | STRING | Indices or patterns to select items from the list | |
| debugopt | BOOLEAN | true | Enable debug print statements |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| any | any_typ | — |
| string | STRING | — |
| length | INT | — |