Nodes/Mickmumpitz-Nodes/String Selector
ComfyUI Node

String Selector

Pull one prompt out of a batch by number

By mickmumpitz·Created 8 months ago·Updated 10 days ago· 47
String Selector
  • string_batch
  • string
select1

You've got a String Batch node holding a stack of prompts - one per shot, one per variation, one per iteration. Now you want to feed just one of them to a sampler, and change which one from the widget without rewiring anything. String Selector is the node that does that: it takes a string_batch in and gives you a single string out, chosen by a plain number.

It's about as simple as a node gets, and that's its virtue. select is an integer, 1 to 24, defaulting to 1. Index 1 is the first string in the batch, not zero - if you're used to Python indexing, that off-by-one is the only thing that'll ever bite you. Out-of-range values get clamped to the batch bounds rather than erroring, so a select of 99 just returns the last string.

How it works

The String Batch family in this pack passes STRING_BATCH around as a tuple. String Selector reads that tuple and returns string_batch[select - 1], clamped into range. That's the whole mechanism - no hidden handlers, no JS, no state. It pairs directly with String Batch (the batch builder) and plays nicely with the pack's IterStringSelector, which is the same idea but driven by the current iteration number instead of a manual widget.

Where you'd use it

Honestly, the manual widget is the least interesting use. Where it earns its place is wired to a control value - another node feeding the select input - so the chosen prompt changes programmatically. Storyboard work is the obvious case: a batch of one prompt per shot, and the shot number decides which prompt runs. Combine it with the pack's Story & Style Selector (which outputs indices) and you've got a clean data-driven pipeline: story picks the index, String Selector picks the prompt, sampler runs it.

Inputs and output

  • string_batch (STRING_BATCH) - the batch you're picking from, usually out of a String Batch node.
  • select (INT, 1–24) - which entry to return.
  • Output: string (STRING) - wire this into your positive/negative prompt or anywhere a plain string is expected.

Installing

Part of Mickmumpitz-Nodes, so install the pack once. ComfyUI Manager → search "Mickmumpitz" → Install → restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/mickmumpitz/ComfyUI-Mickmumpitz-Nodes

Just the usual lightweight deps (numpy, Pillow, opencv-python), no downloads.

Gotchas

If you wire a STRING_BATCH into something expecting a STRING and it refuses the connection, you've skipped this node - the batch type isn't a string, and this is the adapter that unpacks it. Also remember the batch is positional: if you reorder strings in the String Batch node, the numbering here follows the new order. There's no name-matching, so keep your batch order documented or you'll be chasing ghosts when the wrong prompt comes out at index 3.

CategoryMickmumpitz/String Batch

Inputs (2)

NameTypeDefaultDescription
string_batchSTRING_BATCH
selectINT11–24

Outputs (1)

NameTypeDescription
stringSTRING