Nodes/ComfyUI-LZNodes/LZ Prompt Replace Multi
ComfyUI Node

LZ Prompt Replace Multi

Five wildcard slots in one prompt, no regex required

By liz-ils·Created 7 months ago·Updated 12 days ago· 1
LZ Prompt Replace Multi
    • result
    template
    placeholder1
    csv_file1
    placeholder2
    csv_file2
    placeholder3
    csv_file3
    placeholder4
    csv_file4
    placeholder5
    csv_file5

    LZ Prompt Replace Single is nice, but a real variation prompt usually wants more than one moving part. _hair_ and _outfit_ and _setting_, each pulling from its own pool. That's this node: five placeholder/CSV pairs working on one template in a single pass, and each slot picks its value independently and at random.

    The classic use is character library building - the KB's prompt-engineering doc describes exactly this pattern (batch N images of the same person across different cameras, lighting, moods, all from one template). With five slots you can vary subject, hair, clothing, background, and style in one go. Each execution of the node produces a fresh random combination, so a batch of five becomes five genuinely different scenes instead of five near-identical frames.

    The inputs

    • template (multiline) - the base prompt containing up to five distinct placeholders.
    • For each slot i from 1 to 5: placeholder{i} (the marker string) and csv_file{i} (the dropdown of candidate files).

    The dropdowns read from your ComfyUI/output/prompt_csv/ folder - same as the single version. Drop a .csv or .txt there, one option per line, and it appears in the list. Any pair left empty is skipped; the placeholder stays in the template untouched. That means you can build one node with three active slots and two spare, and just fill in slot 4 later without rewiring anything.

    How the replacement happens

    The node processes slots in order, and each one does a literal string replace - not regex, so _hair_ is just the characters _hair_. Slot 1 replaces its placeholder, then slot 2's placeholder is searched for in the result of slot 1. If your placeholders don't collide, order doesn't matter; if they're nested or overlapping, the lower-numbered slot wins. Practical rule: use distinct, obviously-different markers and you'll never think about this.

    What to watch for

    Two things. First, the result is a random pick per slot per execution, and there's no seeding of the randomness - you get what you get. If you want reproducibility, you'd wire the output into something that logs it (LZTextPreview is handy for eyeballing what actually got chosen) rather than trying to predict it. Second, each slot is independent, so the same prompt can combine values that clash. That's usually fine - variety is the point - but if you need "blonde only with rain", keep the dependency logic somewhere else or make one slot drive both.

    And the folder gotcha applies here exactly as it does everywhere in this family: your candidate files must live in output/prompt_csv/ or the dropdown won't list them.

    Installing it

    Same pack, same drill:

    cd ComfyUI/custom_nodes
    git clone https://github.com/liz-ils/ComfyUI-LZNodes
    

    Restart ComfyUI (or ComfyUI Manager → search "ComfyUI-LZNodes"). No extra Python dependencies, no model downloads.

    If managing five CSV files feels heavy for a one-off test, LZ Prompt Replace String replaces a single placeholder from an inline multiline list instead - no files at all.

    CategoryMyCustomNodes/Text

    Inputs (11)

    NameTypeDefaultDescription
    templateSTRING
    placeholder1STRING
    csv_file1COMBO1 options:
    placeholder2STRING
    csv_file2COMBO1 options:
    placeholder3STRING
    csv_file3COMBO1 options:
    placeholder4STRING
    csv_file4COMBO1 options:
    placeholder5STRING
    csv_file5COMBO1 options:

    Outputs (1)

    NameTypeDescription
    resultSTRING