ComfyUI Node

Format String

Template your prompt with [1], [2] placeholders

By nkchocoai·Created 3 years ago·Updated about a year ago· 26
Format String
    • STRING
    prompt[1], [2]
    arg1

    Format String is what you reach for when Join String List's "just stick them together with a separator" isn't flexible enough - you need actual structure, like "[1] wearing [2], standing in [3]", with your own words woven around the variable parts.

    How it works

    You write a prompt template containing [N] placeholders - the default is literally [1], [2] - and the node substitutes each [N] with the matching argN input's value. So a template of "a photo of [1], [2] lighting" with arg1 = "a fox" and arg2 = "golden hour" outputs "a photo of a fox, golden hour lighting". It's basically Python-style string formatting purpose-built for prompt assembly.

    Like Join String List, the base schema only shows a single arg1 slot, but the placeholder syntax implies as many argN as your template references - connect more inputs and the node should pick up [2], [3], and so on. And like Join String List, the author flags this one Experimental too: "there may be some bugs as we have not been able to check the operation very well." Test your template on a throwaway queue before trusting it in a real batch.

    Inputs and outputs that matter

    • prompt - required, the template string with [N] markers. Default [1], [2].
    • arg1 (and further slots as connected) - the values substituted in for each [N].

    Output is a single STRING - the filled-in template, ready for a CLIP Text Encode or another downstream string node.

    Installing it

    ComfyUI Manager → search ComfyUI-PromptUtilities → install → restart. Or:

    cd ComfyUI/custom_nodes && git clone https://github.com/nkchocoai/ComfyUI-PromptUtilities
    

    No models, no extra dependencies - it's one of thirteen small string-utility nodes in this author's pack, all pure Python. Look for it under the PromptUtilities category after restarting.

    Format String vs. Join String List

    Reach for Join String List when your goal is genuinely "N things separated by the same character" - a tag list, basically. Reach for Format String the moment you need literal text around your variables, or when the pieces don't belong at the start/end of a comma list - a full sentence structure, a specific word order, args repeated more than once in the template. Format String does the more powerful job; Join String List does the simpler one with less setup.

    Where people get burned

    The obvious one: if your placeholder count in the template doesn't match the number of args you've actually connected, you're going to end up with a literal, un-replaced [3] sitting in your final prompt - annoying to spot mid-batch, easy to catch by just reading the console log or a Show Text node before you commit to a big run. And because it's flagged Experimental by the author, don't build a deeply nested chain of Format String nodes as your first attempt - start with one template, confirm the substitution behaves the way you expect, then scale up.

    CategoryPromptUtilities

    Inputs (2)

    NameTypeDefaultDescription
    promptSTRING[1], [2]
    arg1optSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING