List to Int Extractor
Pull one value out of a list — safely, with a fallback
- int_list
- extracted_int
- is_valid_index
If Int to List Converter is how this pack packs ints into a list, List to Int Extractor is how you get one back out. You give it a list, an index, and a fallback value; it hands you the value at that index plus a boolean saying whether the index was actually valid.
The "safe" part is what makes it worth using over just reaching into a list yourself: out-of-range indices don't crash the graph, they return your default_value and a clear false flag you can branch on.
How it works
Standard Python list indexing with a guard. If the list is empty, or the index falls outside -len(list) <= index < len(list), it returns the default and is_valid_index = False. Negative indices work like Python - -1 is the last element - so you can grab the tail of a list without knowing its length. The input is declared as a list (INPUT_IS_LIST), and the node indexes directly into it.
Inputs
- int_list - the list to index into. Wildcard-typed, so it accepts lists from any source.
- index - which position to read. Negative allowed (from the end). Range is -999 to 999.
- default_value - what you get back when the index is out of range. Default 0.
Outputs
- extracted_int - the value, or the default.
- is_valid_index - a BOOLEAN you can feed into a Condition Checker or Assignment to branch on whether the extraction succeeded. This pairing is the whole point - a fallback that tells you it fell back.
Install
Standard pack install - ComfyUI Manager (search "ComfyUI-AutoFlow") or:
cd ComfyUI/custom_nodes
git clone https://github.com/ZXL-Xinram/ComfyUI-AutoFlow
Restart after. No extra dependencies.
Where people get burned
- Defaulting silently. If you ignore
is_valid_index, an out-of-range read looks identical to a real read - you just get 0 (or your default). Always check the flag if the index is dynamic. - Feeding it a scalar, not a list. Wildcard input again: a single int connects fine but isn't a list, and the behavior is then undefined-ish. Feed it actual list outputs, ideally from the pack's own Int to List Converter.
- Index vs. position. It's zero-based, like Python. Index 0 is the first element. If you're coming from counting "first = 1," you'll be off by one.
This node completes a tidy round-trip with its pack siblings: pack ints → carry the list → extract by index with a safe fallback. For loop-heavy workflows that need to pick a specific config out of a schedule, it's exactly the plumbing you'd otherwise hand-roll.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| int_list | * | — | |
| index | INT | 0-999–999 | — |
| default_valueopt | INT | 0-999999–999999 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| extracted_int | INT | — |
| is_valid_index | BOOLEAN | — |