Prompt Template (NH)
Fill {placeholders} from real inputs instead of editing text
- result
- missing_vars
If you've ever kept a prompt with {color} and {garment} in it and hand-pasted values in, you've reinvented this node's job - except Prompt Template (NH) does the pasting for you, live, from other nodes in your graph.
You write a template with curly-brace placeholders, tell the node which variables exist via var_names (comma-separated), and connect up to six values (var1 through var6). It replaces each placeholder with its connected value and hands you the finished prompt in result. The default template even shows the shape: a {color} {garment}, {style}, 8k photo with var_names = color,garment,style.
The mechanism is refreshingly direct. Each name in var_names maps positionally to a var input - first name to var1, second to var2, and so on. For each placeholder found in the template, the node replaces it with the connected value. If a value is empty, two things happen: the placeholder is removed from the template, and the variable's name is listed in the missing_vars output (comma-separated). So you always know what the prompt didn't get filled, which beats staring at a hole in the output.
The naming is the only real footgun
Everything hinges on var_names matching the placeholders in your template. If the template says {color} but var_names says colour,garment,style, color never gets replaced and shows up as missing_vars forever. Keep them identical. There's also a positional trap: var1 isn't named, it's the first name in var_names - reorder the list and you've silently swapped which input feeds which placeholder.
A couple of nice touches in the implementation: empty values are cleaned up rather than left as gaps (whitespace from removed placeholders gets tidied), and the fill works with whatever text you connect - pull values from a Random Choice node, a CSV reader, a LoRA-name node, whatever. This is the natural replacement for hand-templated prompts when you want the template text to stay fixed and the variables to move through your workflow.
Install
It's in the NH-Nodes pack:
- ComfyUI Manager → search NH-Nodes → install → restart ComfyUI. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt
Then restart ComfyUI.
No models, no heavy deps - plain string work.
Common issues
Missing placeholders are the classic complaint, and missing_vars exists precisely to diagnose them - if it lists a name, your template placeholder and var_names entry don't match. The other gotcha is the six-input ceiling: only six variables, so keep templates under that or chain two Template nodes. And remember the output is a STRING - wire it into anything that takes a prompt, or into another text node. It won't encode the prompt itself; you still need a CLIP encoder downstream.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| template | STRING | a {color} {garment}, {style}, 8k photo | — |
| var_names | STRING | color,garment,style | — |
| var1opt | STRING | — | |
| var2opt | STRING | — | |
| var3opt | STRING | — | |
| var4opt | STRING | — | |
| var5opt | STRING | — | |
| var6opt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| result | STRING | — |
| missing_vars | STRING | — |