Nodes/comfyui-jz/jz Choice
ComfyUI Node

jz Choice

The pick that survives a reordered list

By j-zhang19·Created about a month ago·Updated 6 days ago· 2
jz Choice
    • value
    • index
    choices
    choice
    separatornewline

    Most "pick one of these" nodes in ComfyUI work by index: they grab whatever string sits at position 3, and if you reorder the list upstream, you silently start picking something else. jz Choice picks by name instead. You type the option you actually want, and the node checks that it still exists - so a reordered or extended list either still matches or fails loudly, listing every option that was available. For a beginner that's the difference between a confusing "why did my prompt change" moment and an error message that tells you the exact fix.

    It's a tiny node and it does one job, but it's the kind of thing that saves real head-scratching in workflows that generate prompts or filenames from a text list. It lives in the jz/util section of the pack, alongside its sibling jz String Picker. Same family, different philosophy: the picker is "give me a random one," Choice is "give me this one, or tell me it's gone."

    How it works

    You feed the node a choices STRING with one option per line (or separated by comma, semicolon, or pipe via the separator dropdown). Then there's the choice text field - the option to pick. When the run happens, the node splits the list, strips blank lines, and checks that choice is literally one of the entries. If it is, you get the value back plus its index (its position in the list, as an INT - useful if something downstream is index-based). If it isn't, it raises with the full list of options in the error, which is a much nicer failure than a silent wrong pick.

    The clever part comes from a small frontend script the pack ships (web/jz_choice.js): when choices is wired from a node holding a literal string - a primitive or string-literal node - the choice widget upgrades itself into a real dropdown that live-refreshes as you edit the list. When the choices are computed at runtime by another node, it stays a plain text field and you just type the value. Either way the validation at run time is what protects you.

    The two inputs that matter

    • choices - the option list, one per line (or per separator). This is a socket, not a widget; wire it from a text node so it's easy to edit in one place.
    • choice - the one to pick. Must match an entry exactly (whitespace is stripped), or the node refuses to run.

    That's really it. Outputs are value (STRING) and index (INT).

    Installing it

    The whole pack is one clone:

    cd ComfyUI/custom_nodes
    git clone https://github.com/j-zhang19/comfyui-jz
    

    Then restart ComfyUI. Or use ComfyUI Manager and search for "comfyui-jz." No model files, no GPU needed, and the only real dependencies are requests, pillow, and numpy, which you almost certainly already have. Nodes appear under the jz/util menu.

    Common issues

    The one failure mode worth knowing: if you leave choice empty or type something that isn't on the list, the node refuses to run with a message like 'x' is not one of the choices: a, b, c. That's the feature working - fix the typo or add the option. And because the dropdown upgrade only kicks in for literal string sources, don't be surprised when a runtime-computed list gives you a plain text field; that's by design, and the run-time check still has your back.

    One honest caveat: this is a personal pack from a solo author (Jacques, published as "amaunra"), and it has basically zero community footprint - no tutorials, no forum lore. The README is your documentation. That's fine for a utility this small, just don't expect a support community.

    Categoryjz/util

    Inputs (3)

    NameTypeDefaultDescription
    choicesSTRINGthe available options, one per line (or per separator)
    choiceSTRINGthe option to pick — must be one of the choices
    separatoroptCOMBOnewline4 options: newline, comma, semicolon, pipe

    Outputs (2)

    NameTypeDescription
    valueSTRING
    indexINT