ComfyUI Node

Prompt Template

The two-line node that saves you from retyping prompts

By aws-samples·Created 2 years ago·Updated about a year ago· 30
Prompt Template
    • STRING
    prompt
    prompt_template

    This node has an "Amazon Bedrock" repo as its home, but the name is a lie - it doesn't call any API, needs no AWS account, and works the moment ComfyUI loads. It's a string templating node, and it's genuinely useful if you build the same kind of prompt over and over.

    What it does

    You give it two strings: a prompt and a prompt_template. It replaces the literal placeholders {prompt} and [prompt] in the template with your prompt, and hands back the finished string. The entire implementation is two str.replace calls - there is no magic, no LLM, no model download.

    So instead of retyping a wall of quality boilerplate every time, you keep a template like:

    cinematic lighting, 85mm lens, shallow depth of field,
    {prompt}, highly detailed, sharp focus
    

    and wire a subject prompt into it. This matters more than it sounds: the Bedrock pack's own example workflow uses prompt templating to wrap a raw idea before sending it to an image model, and prompt structure genuinely changes results on modern models (see the KB's prompt-engineering essay - on LLM-encoded models your prompt is an instruction, and how you structure it is most of the game).

    Why you'd reach for it

    • Standardize a style block across a whole workflow without editing ten nodes.
    • Add the same negative-ish instructions or camera framing to every generation.
    • Compose an LLM-refined prompt (from the pack's Claude/Nova nodes) with your raw input before it hits an image model.

    The output STRING wires into anything that takes a string - a Nova Canvas node, a Stability node, a checkpoint loader's positive prompt, whatever.

    The inputs that matter

    Only two, both multiline:

    • prompt - the thing that varies between runs.
    • prompt_template - the thing that stays the same, with {prompt} or [prompt] where the variable goes.

    Both are required. If your template has no placeholder, you get the template back verbatim - check for a typo before wondering why nothing changed.

    Installing it

    You're installing the whole Bedrock pack to get a five-line utility, which is fair enough because the pack is small and has no heavy dependencies:

    cd ComfyUI/custom_nodes
    git clone https://github.com/aws-samples/comfyui-llm-node-for-amazon-bedrock.git
    pip install -r comfyui-llm-node-for-amazon-bedrock/requirements.txt
    

    Restart ComfyUI, or install via ComfyUI Manager by searching "Amazon Bedrock".

    Gotchas

    • Replacement is exact and case-sensitive: {Prompt} won't match {prompt}.
    • It replaces all occurrences, not just the first - fine here, surprising if your template mentions {prompt} in prose.
    • There's no escaping mechanism. If you want a literal {prompt} in the output, you're out of luck; nobody's building that edge case into this.

    If you need two variables in one template, this pack ships the sibling node "Prompt Template with Two Inputs" for exactly that.

    Categoryutils

    Inputs (2)

    NameTypeDefaultDescription
    promptSTRING
    prompt_templateSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING