ComfyUI Node

Template Filler

Fill in the blanks — structured prompts from random slots

By Ckrest·Created 8 months ago·Updated 4 months ago· 0
Template Filler
    • STRING
    template{slot_1} {slot_2}
    slot_1
    slot_2
    slot_3

    Template Filler turns a prompt into a mad-lib. You write a template with {slot_1} placeholders, connect random selections or fixed strings into the slots, and the node produces the finished sentence. It's the pack's answer to "how do I keep prompt structure stable while swapping the parts," and it pairs naturally with the Random Selectors - the pack's own guide suggests a template like A {slot_1} {slot_2} wearing {slot_3}, {slot_4} lighting with each slot fed by a different pool.

    How it works

    The mechanism is Python's str.format() under a thin wrapper. The template field is your prompt with placeholders named slot_1 through slot_3, and each slot input is a wire from a selector or a plain string. The node fills the placeholders and returns the result as a single STRING.

    The detail worth knowing: a missing placeholder doesn't crash the workflow. If your template references a slot that didn't get connected, you get back an error string - [Template Error: Missing ...] - instead of a hard failure. That's friendly, but it's also a trap: that error text will happily flow into your CLIP encoder and become part of your prompt. If your images start getting weird, check for a literal "[Template Error" in the prompt.

    One asymmetry to be aware of: the shipped code exposes three slots (slot_1slot_3), even though the pack's written guide describes up to ten. If you need more placeholders, chain two Template Fillers or move up to the Freezable String Combiner, which has real headroom.

    The inputs that matter

    • template - the sentence with {slot_1}, {slot_2}, {slot_3} placeholders. The only widget you'll edit by hand.
    • slot_1 / slot_2 / slot_3 (optional) - wire in the values. Leave one unconnected and the placeholder becomes an error string, not a blank.

    Output: one STRING, your finished prompt.

    How to install

    The pack is a dependency-free clone-and-go - no pip installs, no model downloads, pure stdlib:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Ckrest/comfyui-easy-randomize.git
    

    Restart ComfyUI, or install "comfyui-easy-randomize" via ComfyUI Manager. The node registers under Local Custom/Utilities.

    Where it fits

    The sweet spot is the structured-prompt pattern: keep the grammar constant and randomize only the vocabulary. Subject position always has a person, action position always has a verb, because the template enforces it - no random pool can produce a structurally broken sentence. That's a real quality win for batch variation work, where unstructured wildcard prompts tend to drift into incoherence. It's a small, quiet node from an obscure pack, but it earns its slot in a randomize-and-freeze workflow. For the tiny job it does, it does it right.

    CategoryLocal Custom/Utilities

    Inputs (4)

    NameTypeDefaultDescription
    templateSTRING{slot_1} {slot_2}
    slot_1optSTRING
    slot_2optSTRING
    slot_3optSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING