Template Variable From String
When another node already made the string, just slap a name on it
- variables
Template Variable From String is the wire-fed version of the pack's basic creator node. Where Template Variable takes its value from a text box you type into, this one takes a string that already exists elsewhere in your graph and gives it a name so your templates can reference it. That's the entire job, and it's a genuinely useful one.
The classic setup: you have a node that produces text - a file-name node, a random-word picker, an LLM prompt writer, even another prompt template - and you want that text to fill a slot in a different prompt. Without this node you'd have to copy the output and paste it somewhere, which defeats the point of having a node graph. With it, the string flows over a wire, gets named, and becomes a variable like any other.
The inputs
- name - the variable name (
character1,location, whatever your template references). Single line, defaultcharacter. Same validation as the rest of the pack: starts with a letter or underscore, then only letters, numbers, underscores, hyphens. - value - the connected string input. This is what's different from the plain Template Variable node: the value arrives over a wire rather than being typed. It's an optional input, so the node won't scream at you if you haven't connected it yet - though an unconnected value means an empty variable, which is its own quiet failure if you forget.
The output is one variables (TEMPLATE_VARS) socket, same as every creator node in this pack. Like the others, values get whitespace-trimmed when they arrive.
Why not just use the plain Template Variable?
You'd use Template Variable when you're going to type the value yourself and keep editing it in the node. You'd use From String when the value is owned by another node and you want to avoid duplicating it. The tell is where the text lives: if you'd have to copy-paste it into a widget to use the basic node, this is the one you want. It keeps a single source of truth for the value - change it upstream and every prompt using it updates on the next run, no re-pasting.
It's also the node you reach for when a prompt-generating LLM node feeds your positive prompt: name its output subject, template it into the scene sentence, and you get the LLM's variety while keeping the sentence structure you tuned by hand. That workflow - structured template plus generated content in the slots - is exactly the direction the community's been pushing prompt tooling, and this is a small, no-drama way to do it.
Realistic usage
Like every creator node here, it usually sits upstream of a Merge Template Variables, then into Apply Template Variables or the pack's CLIP Text Encode node. If you've got several such values coming in from wires, skip building a row of these and use Template Variables From Strings instead - it takes a names list and up to a hundred connected strings in one node.
Installation
Part of boobkake22/ComfyUI-TemplateVars - no dependencies, no model files. Install via ComfyUI Manager (search "Template Vars") or cd ComfyUI/custom_nodes && git clone https://github.com/boobkake22/ComfyUI-TemplateVars, then restart. Nodes appear under Template Vars.
Worth knowing: this node's value is marked as a "forced input" - it won't render as a text box you can type into, just a socket. If you load a workflow that used a plain value widget here, you'll see an unconnected input and an empty variable, which is the one confusing failure mode people hit. Connect something to the wire and the name starts resolving again.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| name | STRING | character | — |
| valueopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| variables | TEMPLATE_VARS | — |