String Template Parser
A {{ placeholder }} replacer for prompts, filenames, and API payloads
- result
String Template Parser is one of those glue nodes you don't miss until you need it: you give it text with {{ placeholders }} inside, and it swaps in the values you provide. That's the whole job - a string in, a string out. No API, no model, no API key. The name is a lie in the best way: it doesn't call anything, it just runs a regex and a bit of JSON parsing locally.
Where does that fit in a workflow? Prompts, mostly. The classic pattern: keep one long, carefully tuned prompt template as a single text node, then swap a variable like the subject, the model name, or a LoRA trigger in per batch without hand-editing the whole block. It's equally handy for filename templates in save workflows, for building JSON payloads when you're scripting the API, or for that one friend who wants to run the same style prompt across a dozen seeds and only change a keyword each time. If you've ever built the same thing with a pile of Text Concatenate nodes, you'll appreciate how much simpler this reads.
How it works
The node scans source_text for placeholders of the form {{ name }} and substitutes them from a mapping. There are two ways to build the mapping:
- Single replacement: set
variable_nameandreplacement_text. Any placeholder matching that name gets the text. - Batch replacement: set
replacements_jsonto a JSON object like{"model": "flux-dev", "steps": "28"}and it applies to every placeholder in one pass. If both are provided, the JSON wins and the single pair only fills in names the JSON didn't cover.
The interesting edge case is what happens to placeholders nobody supplied. By default they're left untouched - the {{ name }} stays literal in the output. Flip replace_missing_with_default on and missing placeholders collapse to default_for_missing instead. That's handy when you're reusing one template across contexts where some variables don't apply.
The inputs, quickly
- source_text - the template.
- variable_name / replacement_text - the single-pair replacement.
- replacements_json - multiline field for the batch JSON object.
- default_for_missing / replace_missing_with_default - the fallback behavior.
One output, result, a plain STRING. Wire it into a save-text node, a prompt input, or anything else that eats a string. Note the placeholder grammar is strict-ish: names can use letters, digits, underscores, and hyphens, with spaces inside the braces allowed.
Common gotchas
- Bad JSON is silently ignored. If
replacements_jsondoesn't parse, the node doesn't error - it just drops the mapping and keeps going. If your placeholders come back unreplaced, check the JSON first. - Unmatched placeholders stay literal. Expect
{{ name }}to survive in the output unlessreplace_missing_with_defaultis on. That's a feature, but it surprises people who expect an error. - It's a string node. It can't touch numbers, images, or latents. Convert anything you need into text upstream.
Install
It's part of Nynxz/ComfyUI-NynxzNodes, on the Comfy Registry under publisher nynxz. ComfyUI Manager: search "Nynxz" or "ComfyUI-NynxzNodes", install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/Nynxz/ComfyUI-NynxzNodes
Then restart. Zero extra dependencies - the implementation is stdlib re and json only, so nothing to pip-install and nothing to download. The pack targets the newer comfy_api.latest API, so if the node doesn't show up after restart, update ComfyUI first.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| source_text | STRING | — | |
| variable_name | STRING | — | |
| replacement_text | STRING | — | |
| replacements_json | STRING | — | |
| default_for_missing | STRING | — | |
| replace_missing_with_default | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | STRING | — |