ComfyUI Node

String (Inline)

Prompt templates with placeholders that actually get replaced

By nova452·Created 3 months ago·Updated 29 days ago· 509
String (Inline)
    • STRING
    text{{text_a}}
    text_a
    text_b

    Most prompt-building in ComfyUI is concatenation - a hundred Concatenate nodes stringing fragments together. That works, but it's clumsy when you want a template with two things that change. String (Inline) from the Rebalance Pack is the template approach: you write one multiline string with {{text_a}} and {{text_b}} placeholders in it, wire two other string inputs in, and it substitutes the actual values into the template. One node, one template, two moving parts.

    It's the small idea that saves you from the worst of node spaghetti: instead of "a photo of " + subject + " in " + style + ", " + extra, you write one readable template and feed subject and style in as slots.

    How it works

    The text input is your template, defaulting to just {{text_a}}. The optional text_a and text_b inputs (both forced to be connection slots, so you wire values in rather than typing them) replace every occurrence of their token in the template. The node does a literal string replacement - {{text_a}} → the value of text_a, {{text_b}} → the value of text_b - and returns the assembled string. If you don't connect a value, the token stays as-is, which is a deliberate design choice: an unconnected template still produces something (with the literal placeholder visible), and you can use that as a visual check of what's missing.

    Because it's a plain string out, it drops straight into any CLIPTextEncode, a text-concat chain, or a wildcard. And the multiline text field means your template can be a full multi-line prompt with the placeholders embedded in the prose - no more stacking nine single-line fragments.

    The inputs and outputs that matter

    • text - the template. Multiline. Write your prompt with {{text_a}} and {{text_b}} where the changing parts go.
    • text_a / text_b (optional) - the values. The tooltips say it plainly: replaces every {{text_a}} token in the text.

    Output: STRING, the finished template.

    Install

    Part of the Rebalance Pack. ComfyUI Manager: search "ComfyUI-Conditioning-Rebalance" (or "Rebalance Pack"). Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/nova452/ComfyUI-ConditioningKrea2Rebalance
    

    Restart afterwards. No models, no dependencies - it's pure string handling.

    Troubleshooting

    The two limits to know. First, it's exactly two placeholders: text_a and text_b. Need a third? Chain a second StringInline, or use the pack's Concatenate for more traditional joining. Second, the replacement is literal and case-sensitive - {{text_a}} with a space inside, or {{Text_A}}, won't match, so keep your template tokens byte-identical to the input names. And remember the "unconnected token stays visible" behavior: if your final prompt contains a raw {{text_a}}, you'll know at a glance that a slot isn't wired. That's a feature, honestly - a missing connection announces itself instead of silently producing garbage.

    CategoryRebalance-Pack/foundational

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING{{text_a}}
    text_aoptSTRINGReplaces every {{text_a}} token in the text.
    text_boptSTRINGReplaces every {{text_b}} token in the text.

    Outputs (1)

    NameTypeDescription
    STRINGSTRING