Nodes/ComfyUI-Prompt-Preset-Selector/Prompt Preset Selector
ComfyUI Node

Prompt Preset Selector

Wildcard blocks without the wildcard syntax — one spinner, every prompt variant

By shin131002·Created 8 months ago·Updated 2 days ago· 2
Prompt Preset Selector
    • text
    • preset_list
    • selected_info
    preset_file
    absolute_path
    keyword
    keyword_modeOFF
    selection_modeManual
    preset_index0
    seed0

    The old wildcard trick - write {this|that|the other} in a prompt and let each run pick a combination - is one of the best ways to batch variety without writing more prompts. PromptPresetSelector is that idea, but deterministic: instead of randomly picking, a single index spinner chooses the option for every block in your text at once. Flip it and your whole prompt swaps to another preset. It's the most feature-packed node in ComfyUI-RE-CustomUtils, and the one you'll probably build a workflow around.

    The core idea

    You write text with {% ... %} blocks, options separated by |:

    This is {% an example | a text | another text %} for {% the PromptPresetSelector | the README | %}
    

    With preset_index at 0 you get "This is an example for the PromptPresetSelector"; at 1, "This is a text for the README"; at 2, "This is another text for". Every block must have the same number of options, and the index picks that option out of every block. Empty options are legal - the block just collapses to nothing.

    That means one node holds a whole family of prompts: a base template with the subject, framing, lighting and style each as a block, and you sweep the index to generate variations. It's the bracket trick from the A1111 days, minus the randomness and minus the syntax everyone forgot.

    The inputs that matter

    • syntax - defines open_tag separator close_tag, space-separated. Default {% | %}. Want << a / b >> blocks? Set << / >>.
    • preset_index - the selector, 0-based, and it loops in both directions when you spin past the ends.
    • preset_names + preset_name - fill preset_names with neutral, happy, sad and the spinner becomes a named dropdown instead. Fewer names than presets? The rest auto-name (preset_2, preset_3…). More names than presets? Extras are ignored.
    • text - your template with blocks. It gets a syntax-highlighted editor (tags in orange, inactive presets gray) and supports Ctrl+Up/Ctrl+Down to weight the word under the caret, native ComfyUI style.
    • cleanup - on by default; strips the comma-and-paren debris that empty presets leave behind.

    There's also $N reference syntax for stacking presets on top of each other:

    {% base style | $0, hat | $1, jewelry %}
    

    Preset 1 includes preset 0 plus "hat"; preset 2 includes preset 1 plus "jewelry". References resolve recursively, but only backwards - you can't reference a preset declared after the current one, and circular references error out. It's a neat little dependency system for prompt layers.

    Outputs: text (the resolved prompt), preset_index (echoes your selection), and preset_count (how many options the blocks hold - handy for looping a batch).

    Installing it

    It's in ComfyUI-RE-CustomUtils. ComfyUI Manager → search the pack title, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/relhamdi/ComfyUI-RE-CustomUtils
    

    Restart ComfyUI. No extra dependencies - the pack only declares torch.

    Where people get burned

    The node is strict on purpose, and it stops the workflow rather than guessing:

    • syntax must be exactly three space-separated parts, and the open/close tags must differ.
    • All blocks must have the same option count. Mix a 2-option block with a 3-option block and it refuses.
    • Index out of range raises.

    That strictness is a feature when you're pasting a workflow someone shared - a template that violates the rules fails loudly instead of quietly producing a mangled prompt. The one thing to watch: the syntax-highlighted editor is picky about how you format blocks, so if a highlight looks off, check your syntax field first.

    Categorytext

    Inputs (7)

    NameTypeDefaultDescription
    preset_fileCOMBO1 options: (No preset files found)
    absolute_pathSTRING
    keywordSTRING
    keyword_modeCOMBOOFF3 options: OFF, AND, OR
    selection_modeCOMBOManual4 options: Manual, Sequential, Sequential (continue), Random
    preset_indexINT00–9999
    seedINT00–18446744073709550000

    Outputs (3)

    NameTypeDescription
    textSTRING
    preset_listSTRING
    selected_infoSTRING