Template Variables From Strings
Build your whole variable map at once
- values
- variables
This is the pack's batch creator: it takes a list of names and a bunch of connected strings and produces one merged TEMPLATE_VARS map. Where Template Variable From String makes one named variable, this makes many - the node you reach for when three, six, or twenty values are coming over wires and you don't want a wall of single-variable nodes.
It's also the one with the cleverest frontend trick in the pack, and the one most likely to confuse you on first sight, so it's worth a minute.
How it works
Two inputs do the job:
- names - one variable name per line in a multiline box.
character1on line one,character2on line two,locationon line three. - values - the connected strings, one per socket. On current ComfyUI this is a dynamic (Autogrow) input: it starts with a single
value0socket and grows as you connect more, up to 100. On older builds it's fixed at ten inputs namedvalue_1throughvalue_10.
The values pair up with the names by index: the first name with the first connected value, and so on. The README's example is the whole story - names character1, character2, location paired with values Alice, Bob, a rainy train station produces { "character1": "Alice", "character2": "Bob", "location": "a rainy train station" }, ready to feed straight into the pack's CLIP Text Encode node. No merge node needed.
The part that's easy to miss
When the frontend helper loads, the names text box is hidden and replaced by one single-line name widget generated for each connected valueN input - right on the wire, next to the string it names. That's nicer to work with, but it means what you see depends on how many wires are connected, and those generated name widgets are synced back into names so the workflow stays loadable on ComfyUI instances that don't load the helper.
Two gotchas fall out of this. First, if a name line is blank or missing, the node silently falls back to value0, value1, etc. for that index - so a missed name produces a technically-valid variable named value2, which almost certainly isn't what your template references. Second, on an older ComfyUI build the helper won't run, so you'll type names one per line in the names box and count carefully against the fixed value_1, value_2 inputs. The backend field is the fallback, and the frontend is the convenience; they're kept in sync on purpose.
When you'd actually use it
This shines when your strings come from other nodes - a set of prompt fragments, per-character descriptions from a spreadsheet or a text loader, LoRA trigger words pulled off a file. One node, a names list, and the whole map exists. If your values are hand-typed literals you're still editing, plain Template Variable nodes (one per value) are usually clearer; the batch node's index pairing gets fiddly when you're also adding and removing values mid-edit.
Installation
Same pack, same story: boobkake22/ComfyUI-TemplateVars, zero dependencies, no models. Install via ComfyUI Manager (search "Template Vars") or cd ComfyUI/custom_nodes && git clone https://github.com/boobkake22/ComfyUI-TemplateVars, then restart, and look under Template Vars.
If your variable names suddenly show up as value3 in the rendered prompt, check your names list against the connected wires - that's the fallback naming kicking in. And if a string isn't appearing at all, it's because the node skips any value that isn't connected (the pack explicitly skips None), so an unplugged middle slot shifts nothing but may not be obvious at a glance.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| names | STRING | value0 | — |
| values | COMFY_AUTOGROW_V3 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| variables | TEMPLATE_VARS | — |