StringToolsRandomChoiceList
Same seedable picker, but your options arrive as a list
- STRING
The list-fed sibling of the pack's headline node
StringToolsRandomChoice is the famous one: dynamic text_0, text_1, … slots, seed-driven pick, deterministic output. StringToolsRandomChoiceList is the same idea with one crucial difference - instead of one wire per alternative, it takes a single list of strings on a text_list port and picks one of them by seed.
So when do you use this over the non-list version? When your options already are a list. The natural source is StringToolsStringsToList - bundle several StringToolsString/StringToolsText wires into a list and feed it here - or any other node that outputs a list of strings. If you're typing alternatives directly into a few slots, the plain StringToolsRandomChoice is simpler and you don't need this one. If your alternatives come from elsewhere as a collection, this is the one.
How it works
Two required inputs: seed (INT, default 0) and text_list (a STRING list, force-input - you can't type a list into a widget, so it must be wired from a list producer). It's an INPUT_IS_LIST node, so the whole list arrives on that single port. At run time it flattens the list (in case you get nested lists from upstream), seeds Python's random with your seed, and returns one randomly chosen element. Same seed, same pick - the same determinism contract as the sibling node. An empty list returns an empty string, so check the list producer before blaming the pick.
One handy property: because it flattens, you can feed it a list that was itself assembled from multiple lists and it'll just pick across everything. And like every node in this pack, it refuses PrimitiveNode connections - but since text_list is a list port wired from a list-producing node, you probably weren't using a PrimitiveNode there anyway.
The inputs that matter
- seed (INT, default 0) - the only thing you'll change to re-roll. Wire a
StringToolsSeedin if you want the number to live in one visible place. - text_list (STRING list) - your alternatives. Wire from
StringToolsStringsToListor any other list-of-strings source.
Output is a single STRING - the chosen option, ready for a prompt encode, a concat, a note, whatever consumes it.
Installing it
Same one-pack install. ComfyUI Manager: "Install Custom Nodes", search ComfyUI String Tools (repo Taremin/comfyui-string-tools), install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/Taremin/comfyui-string-tools
Restart fully. No pip dependencies, no model files, MIT licensed, release 0.0.7.
Gotchas
- It doesn't take individual text wires. If you try to connect a
StringToolsStringoutput intotext_list, you're handing a single string where a list belongs. Bundle first withStringToolsStringsToList. - Empty list → empty string out. Watch for it when you disconnect part of an upstream bundle.
- It's uniform random across all elements - there's no weighting here. If you need weighted picks, that's
StringToolsBalancedChoiceList, which takes the same list and adds aweight_list.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| seed | INT | 00–18446744073709550000 | — |
| text_list | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |