StringToolsRandomChoice
The seedable pick-one-of-several node this pack exists for
- STRING
The one node that justifies the whole pack
Every other node in ComfyUI String Tools is support staff for this one. StringToolsRandomChoice takes a handful of string inputs and, driven by a seed, hands you back exactly one of them. Same seed, same pick - every time. That's the entire trick, and it's enough to make batch prompt variation a solved problem: wire your positive prompt alternatives into it, feed it from a seed node, and you get deterministic variation you can actually reproduce.
Here's the thing that makes it exist. ComfyUI's normal "convert widget to input" mechanism produces a PrimitiveNode, and this node - like StringToolsConcat - refuses connections from a PrimitiveNode. The author blocks them deliberately in the JS. That's why the pack ships its own StringToolsString / StringToolsText source nodes and its own StringToolsSeed: so you can build the whole string subgraph without ever touching a PrimitiveNode. The README says this in so many words, and it's worth knowing before you blame yourself for a wire that just won't connect.
How it works
Drop the node on the canvas and you get a seed input and one text_0 slot. Connect a string into text_0 and the node spawns a fresh empty text_1 beside it; connect that and text_2 appears. Unplug things and the empty slots tidy themselves away. The inputs are slots only - you can't turn them into widgets, and double-clicking an empty slot creates a StringToolsText node instead of a PrimitiveNode. It's the same dynamic-slot trick the Impact and rgthree packs popularized, and it means you never have a fixed cap on alternatives.
At run time it collects every connected text_N input, sorts them by their number (so text_2 always sorts after text_0), does random.seed(seed) followed by random.choice(...), and returns the winner. Deterministic: same seed, same alternatives, same result on any machine. The seed input is an INT defaulting to 0 - type a number if you like, but the intended wiring is a StringToolsSeed node feeding the port, since PrimitiveNode won't connect there either.
The inputs that matter
- seed (INT, default 0) - the only required input. Change it to get a different pick.
- text_0, text_1, … - your alternatives. They appear as you connect things. Empty or disconnected slots are simply ignored; if nothing is connected at all, the node returns an empty string, so check your wires first when output comes back blank.
The output is a single STRING - wire it into any text input downstream: your CLIP Text Encode, a StringToolsConcat, a note node, whatever.
Installing it
Via ComfyUI Manager: "Install Custom Nodes", search for ComfyUI String Tools (repo Taremin/comfyui-string-tools), install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Taremin/comfyui-string-tools
Then fully restart ComfyUI. No pip dependencies, no model downloads - this pack is stdlib Python plus one JS file. It's from Taremin, the same dev behind the well-regarded WebUI Monaco Prompt editor, so prompt tooling is clearly the home turf here. Current release 0.0.7, MIT.
Gotchas
- Same seed, same pick is the feature, but it also means "shuffle" doesn't exist - to re-roll you change the seed. Many people wire a
StringToolsSeedin and bump it. - If a text input won't accept your wire, it's almost certainly a PrimitiveNode at the other end. Swap it for a
StringToolsStringorStringToolsText. - Don't confuse this with wildcard/dynamic-prompt packs. If you want
{2$$a|b}-style syntax, that's a different family of tools; this node is for explicit, seedable choice, which plays nicer when you need reproducibility.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| seed | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |