Nodes/ComfyUI_Eugene_Nodes/Dictionary Template
ComfyUI Node

Dictionary Template

Turn {placeholders} Into Real Prompts, Programmatically

By JEONG-JIWOO·Created 2 years ago·Updated 8 months ago· 2
Dictionary Template
  • dictionary
  • STRING
template_text

Here's the payoff node of Eugene's whole dictionary scheme. You've spent a little effort building a dictionary of reusable values - style tokens, quality tags, negative terms - and the Dictionary Template node is what spends it. Give it a template string full of {placeholders} and a dictionary, and it produces the final text with every placeholder replaced by its value. For prompts, it's the difference between editing the same text in fifteen places and editing it in one.

How it works

The mechanics are about as straightforward as a node gets. It takes template_text (multiline, so paste entire prompt blocks) and a dictionary (DICT, from any of the pack's update nodes). For every key in the dictionary, it looks for {key} in the template and swaps in the value. Output is a single STRING.

Because it's a simple find-and-replace over the whole template, you can nest values and use the same key more than once - put {style} in both the subject line and the negative line and both get filled. A common setup:

  1. DictUpdate1 / DictUpdate5 build a dictionary: {subject}, {style}, {quality}, {neg}.
  2. DictTemplate holds your full prompt skeleton, e.g. "A {subject} in {style}, {quality}, masterpiece".
  3. The resulting string feeds a normal CLIP Text Encode.

Change one value in the update node and every template reading that key updates with it. This is also exactly how the pack's LoRA loader nodes handle {key} placeholders in prefix/suffix text - same syntax, same idea.

The one gotcha to remember

Any {key} in the template that isn't in your dictionary stays as literal text. That's actually your best debugging signal: if the output prompt contains a raw {something}, the key is missing from the dictionary - misspelled, never set, or set in a different branch of the graph than the one feeding this template. Check the DictUpdate nodes upstream.

One more subtlety: replacement happens in dictionary order, key by key. If one value contains text that looks like another key's placeholder, a later replace can mangle it. In practice, keep values free of {curly braces} and you'll never see it.

Installing it

Same pack, no extra dependencies:

cd ComfyUI/custom_nodes
git clone https://github.com/JEONG-JIWOO/ComfyUI_Eugene_Nodes

Restart ComfyUI, or install via ComfyUI Manager (search "Eugene Nodes").

Where people get burned

Beyond the leftover-placeholder problem, the usual complaint is "my template is doing nothing" - which is almost always a wiring issue: the dictionary input expects this pack's DICT type, so if your template node isn't connected to a DictUpdate node (or a bus's dict slot), there's nothing to substitute. And since the output is just a string, remember it still has to go through a CLIP Text Encode before a sampler will use it - this node assembles the prompt, it doesn't condition anything on its own.

Categorydictionary/utils

Inputs (2)

NameTypeDefaultDescription
template_textSTRING
dictionaryDICT

Outputs (1)

NameTypeDescription
STRINGSTRING