Nodes/unwdef-nodes/Text Multiline with Variables
ComfyUI Node

Text Multiline with Variables

Fill !var_1 placeholders from other nodes — a tiny prompt mail-merge

By unwdef·Created 2 years ago·Updated about a year ago· 6
Text Multiline with Variables
    • STRING
    textpicture of !var_1 in the style of !var_2
    var_1
    var_2
    var_3
    var_4
    var_5

    Text Multiline with Variables is the boring node that saves you from an enormous amount of copy-paste. You write a prompt skeleton with placeholders like !var_1 and !var_2, then fill those placeholders from the node's inputs. Think mail-merge for prompts: one template, swappable parts.

    Why you'd reach for it

    The natural partner for this is the same pack's Random Text From Multiline. Set your template to something like the default - picture of !var_1 in the style of !var_2 - wire the random subject picker into var_1, wire an artist or style string into var_2, and now every generation rolls a new subject inside the same fixed frame. You get consistent structure with randomized content, which is exactly the setup for farming one style across many subjects.

    How it works

    How it works is about as simple as it gets: the node does a literal string replace of each !var_x placeholder with the matching input value. There's no templating engine, no nesting, no functions - if !var_1 appears in your text, it becomes whatever var_1 holds. The vars are marked forceInput, which just means they show up as input sockets you can wire from other nodes instead of only being typed by hand.

    The fields

    The fields:

    • text - the template with !var_1 through !var_5 inline.
    • var_1 … var_5 - optional string inputs. Leave an unused one empty and its placeholder is simply removed from the output.

    One output, a STRING, goes wherever your prompt does - a CLIP Text Encode for the positive prompt, or a Show Text node to preview before you commit.

    What trips people up

    Two things trip people up. The placeholders are exactly !var_1 - underscore, matching the input name - not !var1 or !var_a. And the replacement is case-sensitive and literal: !VAR_1 in your template won't match !var_1. That's essentially the whole failure surface of the node, which is honestly refreshing.

    Installing

    Install: ComfyUI Manager, search "unwdef", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/unwdef/unwdef-nodes-comfyui.git
    

    Restart and it's there. No dependencies, no models to fetch - just a text node that does exactly what it says. Given how much hand-rolling ComfyUI's text handling normally involves, "exactly what it says" is worth a lot.

    Categoryunwdef/text

    Inputs (6)

    NameTypeDefaultDescription
    textSTRINGpicture of !var_1 in the style of !var_2
    var_1optSTRING
    var_2optSTRING
    var_3optSTRING
    var_4optSTRING
    var_5optSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING