Nodes/comfyui-prompt-append/Conditional Prompt Append
ComfyUI Node

Conditional Prompt Append

Conditional tag appending, no Python required

By COkedat·Created 5 months ago·Updated 5 months ago· 0
Conditional Prompt Append
    • prompt
    • is_detected
    base_prompt
    search_prompt
    search_logic
    append_prompt
    condition
    input_delimiter,
    output_delimiter,
    skip_duplicatetrue
    weight1.00
    position

    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:

    1. It splits base_prompt on a delimiter and builds a set of cleaned tags - brackets stripped, :weight suffixes removed, everything lowercased. So (masterpiece:1.2) counts as masterpiece when matching.
    2. It searches for the tags in search_prompt inside that set, using AND (all must be present) or OR (any one counts).
    3. It decides whether to append based on condition: Always, If Detected, or If Not Detected.
    4. It splits append_prompt, skips any tag that's already in the base prompt (unless you turn skip_duplicate off), and joins what's left.
    5. It sticks the result on the front or back of your base prompt - and only wraps it in a weight bracket if you changed weight from 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, or If 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. sword matches (sword:1.2); it will not match "a sword" as a phrase. This is a tag tool, not a natural-language tool.
    • is_detected fires regardless of what condition does. If you set If Not Detected and 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 position to front when you want the appended content to matter more, back when 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.

    Categoryutils/prompt

    Inputs (10)

    NameTypeDefaultDescription
    base_promptSTRING
    search_promptSTRING
    search_logicCOMBO2 options: OR, AND
    append_promptSTRING
    conditionCOMBO3 options: Always, If Not Detected, If Detected
    input_delimiterSTRING,
    output_delimiterSTRING,
    skip_duplicateBOOLEANtrue
    weightFLOAT1.000.1–10
    positionCOMBO2 options: back, front

    Outputs (2)

    NameTypeDescription
    promptSTRING
    is_detectedBOOLEAN