Conditional Prompt Append
Conditional tag appending, no Python required
- prompt
- is_detected
You've got one workflow and you want it to serve three different moods - sometimes the character has a sword, sometimes they don't, and you'd rather not rebuild the prompt every run. That's the whole job of Conditional Prompt Append: a tiny utils/prompt node that looks at your base prompt, checks whether certain tags are already in it, and appends extra tags only when the condition you picked is true. Think "if / then" for prompt text, wired straight into your graph.
It's a pure text-processing node. No API, no key, no model download, no GPU work - the entire implementation is one Python file using only the standard library. If you're on a tag-based model (SD 1.5, SDXL, Pony, Illustrious, NoobAI), this is genuinely handy. If you're on an LLM-encoded model like Flux or Anima, read the gotchas below before you get excited.
How it works
The node does five things in order, and understanding the order explains almost every surprise:
- It splits
base_prompton a delimiter and builds a set of cleaned tags - brackets stripped,:weightsuffixes removed, everything lowercased. So(masterpiece:1.2)counts asmasterpiecewhen matching. - It searches for the tags in
search_promptinside that set, usingAND(all must be present) orOR(any one counts). - It decides whether to append based on
condition:Always,If Detected, orIf Not Detected. - It splits
append_prompt, skips any tag that's already in the base prompt (unless you turnskip_duplicateoff), and joins what's left. - It sticks the result on the
frontorbackof your base prompt - and only wraps it in a weight bracket if you changedweightfrom 1.0.
Two outputs come out: the finished prompt string, and is_detected - a BOOLEAN that tells you whether the search tags matched, independent of whether anything was appended. That second output is the sleeper feature. Wire it into a "Show Anything" node or a boolean switch to gate other parts of your graph on the same check.
The inputs that matter
You'll realistically touch four of these per run:
base_prompt- your existing prompt. Everything else is judged against it.search_prompt- the tags to look for. Multi-line input, so you can paste a tag list; newlines are auto-converted to your delimiter.append_prompt- the tags to add when the condition fires.condition- the actual logic switch.Always,If Detected, orIf Not Detected.
The rest have sane defaults: search_logic = OR, skip_duplicate = true, position = back. weight applies to the appended chunk as a whole - (sword, cape:1.2) - not to your base prompt. And yes, weight only does anything on models that respect A1111-style weight syntax in the first place.
Installing it
Simplest path is ComfyUI Manager - search the custom node list for "comfyui-prompt-append" and click install. Or clone it by hand:
cd ComfyUI/custom_nodes/
git clone https://github.com/COkedat/comfyui-prompt-append
Then restart ComfyUI. The node shows up under utils/prompt as "Conditional Prompt Append". That's the entire install - there is no requirements.txt, no models to fetch, nothing to break.
Gotchas worth knowing
- Matching is case-insensitive and weight-blind, but it's exact-tag matching.
swordmatches(sword:1.2); it will not match "a sword" as a phrase. This is a tag tool, not a natural-language tool. is_detectedfires regardless of whatconditiondoes. If you setIf Not Detectedand the search term is found, nothing appends but the boolean still reports the detection. Route the boolean, not your intuition, when you build logic on it.- The weight feature is quietly useless on 2026 LLM-encoded models. The KB's prompt-engineering research is blunt about this: on Flux/Chroma/Qwen-lineage encoders,
(tag:1.2)is silently discarded. This node shines on the danbooru-tag models; on those, expect indifference. - Empty or fully-duplicated appends return your base prompt unchanged. That's not a bug - the node just skips work it doesn't need to do.
- Remember earlier tags get stronger attention on tag-based models. Set
positiontofrontwhen you want the appended content to matter more,backwhen it's flavor.
It's not flashy, and the author isn't a known name in the scene - but for "same workflow, different vibe per run," it's the kind of small string-wrangling tool that quietly saves you from maintaining three near-identical prompt boxes.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| base_prompt | STRING | — | |
| search_prompt | STRING | — | |
| search_logic | COMBO | 2 options: OR, AND | |
| append_prompt | STRING | — | |
| condition | COMBO | 3 options: Always, If Not Detected, If Detected | |
| input_delimiter | STRING | , | — |
| output_delimiter | STRING | , | — |
| skip_duplicate | BOOLEAN | true | — |
| weight | FLOAT | 1.000.1–10 | — |
| position | COMBO | 2 options: back, front |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |
| is_detected | BOOLEAN | — |