Insert Prompt Node
Glue Text Into a Prompt Template (and Get Conditioning Out)
- clip
- clip_output
- string_output
This is the other half of the image-caption-comfyui pack, and it's basically a glorified find-and-replace. You give it a text value, a template string, and it splices the value in wherever you put a {prompt_string} placeholder - then, like its sibling, it emits both a clean string and a finished CLIP conditioning.
Why does that live in a captioning pack? Think about the loop it's built for. Your Image Caption Node spits out a caption like 1girl, solo, forest. You rarely want to generate with that raw - you want it wrapped, 1girl, solo, forest, hdr, best quality. This node is the glue between a caption or prompt source and a sampler, and its trick is that you don't need a CLIP Text Encode node on the other side. The conditioning is already encoded.
How it works
The mechanism is a regex, honestly. It looks for {prompt_string} (whitespace-tolerant, so { prompt_string } works too) in your prompt_format and swaps in the prompt_string value - every occurrence, not just the first. The composed string then gets run through the pack's text cleaner, which collapses double spaces, fixes stray commas and artifacts like ( , or , ), and strips leftover scalar weights. Finally it tokenizes the result with your clip and returns conditioning plus the string.
Inputs and outputs
- clip - a CLIP model, same as the caption node. Only used to encode the final string.
- prompt_string - the text being inserted. Default empty.
- prompt_format - the template, default
{prompt_string}. Multiline, and the placeholder can go anywhere:1girl, solo, {prompt_string}is the author's example.
Outputs are clip_output (CONDITIONING, straight into a sampler's positive input) and string_output (STRING). One quirk worth knowing: the string output has a trailing , appended. That's deliberate - the author built this to feed downstream nodes that append more prompt text (his companion "Prompt Generator" pack), and the comma keeps the concatenation from gluing two words together.
Should you bother?
Honest answer: on its own, no. You can replicate the string half with a Text Concatenate node in five seconds. The thing this gives you is the conditioning output - if you're chaining caption → insert → sampler, it saves you a CLIP Text Encode and keeps one less node in the graph. There's also a genuine bonus: the automatic cleanup. Plain string concatenation won't dedupe keywords or fix the ( , artifacts a captioner can leave behind, and this does that for free.
Installing
Same pack as the caption node, since they ship together:
cd ComfyUI/custom_nodes
git clone https://github.com/alpertunga-bile/image-caption-comfyui
Then restart ComfyUI. Or use ComfyUI Manager and search for "image-caption-comfyui." This node itself is featherweight - it doesn't even touch transformers directly (that's the caption node's dependency). It'll show up in the "image-caption" category alongside its sibling.
Gotchas
There aren't many failure modes here, because there isn't much to fail. The author's one warning covers it: if an updated workflow loads with a broken node, the variables changed between versions - delete the node and re-add it. And remember the trailing comma on string_output; if you're feeding that into a plain text node and the extra , bothers you, that's why it's there.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| clip | CLIP | — | |
| prompt_string | STRING | — | |
| prompt_format | STRING | {prompt_string} | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| clip_output | CONDITIONING | — |
| string_output | STRING | — |