String Switch By Number
Pick one of fifteen prompts by a number
- S
A switch is the classic way to turn "which one?" into "this one," and String Switch By Number is the ComfyUI Logic Support pack's version of it: you give it a number and up to 15 strings, and it hands back whichever string matches. The matching is 1-based - number 1 returns string1, number 5 returns string5. If the number is out of range (below 1 or above 15), it quietly falls back to string1.
That's the whole mechanism, and it's deliberately boring. number is an INT limited to 1–15, string1 through string15 are all STRING inputs, and there's a single STRING output holding the winner. No state, no hidden behavior. It's the textbook case of a node you never think about once it's wired.
Where it earns its keep is downstream of the pack's other number-makers. The README's canonical workflow chains Number Range Index into this node: a number (the example uses age) gets bucketed into a range, the bucket's index becomes the number here, and the node selects the text appropriate for that bucket. Same trick works off a Boolean Index Adder - whichever flag fires first determines which prompt string comes out. One number in, the right text out, no messy webs of conditional nodes.
The one trap worth naming: the off-by-one. Because selection is 1-based, number 2 does not mean "skip the first string" in the way you might instinctively think - it literally means "give me string2." And out-of-range values silently returning string1 can bite you: if an upstream index ever computes 0 or 16, you don't get an error, you get the first option, and that can take a while to notice in a busy graph.
Install is the same one-liner for every node in this pack:
cd ComfyUI/custom_nodes
git clone https://github.com/narusas/Comfyui-Logic-Support
Then restart ComfyUI (or just refresh the tab). ComfyUI Manager also has it if you search for "ComfyUI Logic Support." Pure Python, zero dependencies, no models to download - nothing here can kick off the kind of dependency hell that bigger packs bring with them. MIT-licensed, single-author, and small enough that you won't find much community chatter about it; it's a utility you install once and forget.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| number | INT | 11–15 | — |
| string1 | STRING | — | |
| string2 | STRING | — | |
| string3 | STRING | — | |
| string4 | STRING | — | |
| string5 | STRING | — | |
| string6 | STRING | — | |
| string7 | STRING | — | |
| string8 | STRING | — | |
| string9 | STRING | — | |
| string10 | STRING | — | |
| string11 | STRING | — | |
| string12 | STRING | — | |
| string13 | STRING | — | |
| string14 | STRING | — | |
| string15 | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| S | STRING | — |