Nodes/ComfyUI_BishaNodes/Wildcard Replace
ComfyUI Node

Wildcard Replace

Drop a {placeholder} in your prompt and swap it from a list

By vladpro3·Created about a year ago·Updated 5 months ago· 0
Wildcard Replace
    • prompts
    prompts
    values
    wildcard
    next_linefixed
    start_line0
    values_count1
    value_separator,
    prepend_text
    append_text

    The wildcard idea is a ComfyUI staple - you've seen the whole ecosystem of wildcard and dynamic-prompt nodes where __anything__ gets replaced from a directory of text files. WildcardReplace is a lighter, more explicit take on the same trick: you write a prompt containing a literal token like {person}, feed in a list of candidate values, and the node swaps the token for one (or several) of them. No file browser, no __double-underscore__ convention, no hidden rules. What you see is what gets replaced.

    The inputs spell it out. prompts is your template (or templates - this node accepts a list, so you can run several skeletons through one pass), and it must contain the exact string you put in wildcard. So if wildcard is {person}, your prompt needs {person} in it, case-sensitively, or the prompt passes through unchanged. values is the pool of replacement candidates, also a list - which is where this node shines as a partner to the pack's Load Data From Files, whose whole job is assembling candidate lines from multiple files.

    Then the line-picking machinery kicks in, same as the rest of the pack's prompt nodes:

    • values_count - how many candidates to pull and join together.
    • value_separator - the join string (default ,, so you get Alice,Bob).
    • next_line - increment / decrement / random / fixed, controlling which candidates get picked.
    • start_line - where to start picking from.

    So a portrait of {person} with {object} with a people list and an objects list becomes, say, a portrait of Alice with a sword - and if you set values_count to 2, the replacement becomes Alice,Bob, filling every occurrence of the token at once. The token swap uses plain string replace, so it hits every {person} in the prompt, not just the first.

    The optional prepend_text and append_text wrap the final prompt, joined with your value_separator. The single prompts output is a STRING list, one final prompt per template you fed in.

    Worth knowing before you wire it up: it's a literal replacement, so token naming is on you - {person} and { Person } are different tokens, and a missing token is silently ignored rather than flagged. There's no file reading here at all; if your candidates live in a .txt on disk instead of an input list, you want Wildcard Replace (with values from File) instead. That sibling does the identical swap but pulls its values straight from a file path. And since this node re-runs on every queue (the pack marks prompt nodes always-changed), random mode genuinely re-rolls each run - which is the whole point of a wildcard.

    Install the pack through Custom Nodes Manager (search ComfyUI_BishaNodes) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/vladpro3/ComfyUI_BishaNodes.git
    

    Restart, and you're done. No models, no pip dependencies, MIT-licensed. For a small utility, it's a tidy middle ground between hand-editing prompts and adopting a full dynamic-prompt framework.

    CategoryBishaNodes/prompt

    Inputs (9)

    NameTypeDefaultDescription
    promptsSTRING
    valuesSTRING
    wildcardSTRING
    next_lineCOMBOfixed4 options: increment, decrement, random, fixed
    start_lineINT0
    values_countINT1
    value_separatorSTRING,
    prepend_textoptSTRING
    append_textoptSTRING

    Outputs (1)

    NameTypeDescription
    promptsSTRING