Image Indexes To Int List
Turn '0, 2, 5' Into an Actual List of Numbers
- INDEXES
Strings are for humans, lists are for the graph
Somewhere in your workflow you'll have a widget where you type something like 0, 2, 5 or 1-3, 7 - a human-readable list of image indexes. And somewhere else, a node that wants a proper INT list. Those are two different types, and ComfyUI is annoyingly strict about it. easy imageIndexesToIntList is the one-line converter between them: comma-separated string in, integer list out.
The concrete use case in this pack: the Timeline Info Output emits image indexes - which images belong to which segment - and guide-frame nodes (like the LTX guide-adders) want an actual list of frame indexes to work with. Typing indexes into a text box is natural for a human; feeding them to a node needs them parsed. This node is the bridge.
How it works
It's parsing, and not much more:
indexes = [int(x.strip()) for x in str(image_indexes).split(",") if x.strip()]
Split on commas, strip whitespace, cast to int, drop empties. Empty input string → empty list. A non-integer token → it raises a ValueError telling you exactly what it got, rather than silently producing a partial list. That error-on-garbage behavior is the right call: silently dropping a bad token would give you index-shifted output and a confusing downstream failure.
One thing to note: the parser handles comma-separated integers. The "1-3" range syntax from my opening line is not something this node expands - if you want ranges, expand them before it gets here (or type them out). It's strict by design.
Inputs and output
image_indexes- a plain string, comma-separated integers, e.g.0, 2, 5or3.INDEXES- anINTlist output. Each parsed number, in order.
That's it - no skip_empty, no mode dropdown. It's a converter, and converters shouldn't have opinions.
Setup and the traps
Part of the pack: ComfyUI Manager → ComfyUI-Easy-Media, or git clone into custom_nodes + restart. No models, no FFmpeg, no download.
The realistic failure modes:
- Spaces around commas are fine (
0, 2, 5works). Tabs, newlines, or semicolons are not - keep it comma-separated. - Non-integer input raises.
0, foo, 5fails loudly with "Invalid image_indexes input." The error message includes the offending string, so it's self-explanatory. If you're generating the string dynamically (say, from an LLM), validate it before it gets here. - Index base. Whatever consumes your list decides whether
0means the first image. This node just parses; it doesn't shift bases. If your target is 1-based, add one upstream - don't expect the converter to know. - Empty string → empty list, not an error. If that's not what you want, gate it upstream.
It's about as thin as nodes come - but "string of indexes" to "list of indexes" is a conversion every list-consuming workflow eventually needs, and it's genuinely annoying to rig by hand.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image_indexes | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INDEXES | INT | — |