Shima String Switch
Pick one of eight strings by index, and keep the rest as bonus outputs
- SELECTED
- ALL_CSV
- ALL_TUPLE
- ALL_DICT
A switch is the graph's version of an if-statement: pick one input, pass it through. Shima StringSwitch is that idea for strings - eight optional string_1–string_8 inputs, one index widget (1–8), and the selected string comes out the SELECTED port. It's the same routing valve you get in a dozen other packs, with one difference: it also hands you the whole set in three other shapes.
Those extra outputs are why you'd pick this over a generic switch. ALL_CSV gives you every connected string comma-joined - handy for dumping the full set into a log or filename. ALL_TUPLE is the same values as a Python tuple for any node that eats lists. ALL_DICT is a dict keyed 1–8 with only the connected entries, which is the most useful of the three for scripting-style nodes that address strings by slot. Unconnected inputs are skipped everywhere, so the outputs always reflect what's actually wired, not a padded 8-slot structure.
The inputs
index- the selector, 1 through 8, default 1. Wire it from a counter or a UI node and you've turned the switch into a sequential router; drive it from a seed and it becomes a random-ish picker.string_1–string_8- all optional, all forced as inputs (they can't be turned into widgets). At least one should be connected, obviously.
Output: SELECTED (the string at index), plus ALL_CSV, ALL_TUPLE, ALL_DICT.
How it behaves
Selection is a plain dict lookup on the connected inputs: strings.get(index, ""). That default matters - if index points at a slot you left unconnected, SELECTED is an empty string, not an error and not the first connected value. Silent, but predictable once you know it. There's no fallback logic here; this is the A/B-switch shape, not the first-non-null shape. If you want "give me whichever one is connected," that's a different node (rgthree's Any Switch and its ilk), and this isn't it.
Installing it
Part of KDB-USJP/shima_wf:
cd ComfyUI/custom_nodes
git clone https://github.com/KDB-USJP/shima_wf
Restart ComfyUI. No extra dependencies.
The honest take
For pure single-string routing, any switch does this and you don't need the pack. The reason to reach for this one is the trio of aggregate outputs - if your workflow is the kind that wants the selected prompt and the full list as a CSV for a log, that's all in one node here, which beats stringing together a switch, a concat, and a couple of primitives. Two gotchas to remember: index is 1-based (everyone hits "why is it off by one" once), and pointing at an empty slot silently yields "". Keep those in mind and it's a reliable little router.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| index | INT | 11–8 | — |
| string_1opt | STRING | — | |
| string_2opt | STRING | — | |
| string_3opt | STRING | — | |
| string_4opt | STRING | — | |
| string_5opt | STRING | — | |
| string_6opt | STRING | — | |
| string_7opt | STRING | — | |
| string_8opt | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| SELECTED | STRING | — |
| ALL_CSV | STRING | — |
| ALL_TUPLE | TUPLE | — |
| ALL_DICT | DICT | — |