Nodes/D2-PromptSelector-comfyUI/D2 Prompt Selector
ComfyUI Node

D2 Prompt Selector

D2 Prompt Selector's Token Node

By da2el-ai·Created 2 years ago·Updated 2 months ago· 12
D2 Prompt Selector
    • STRING
    string
    delete_unmatchtrue
    delimiter--
    dynamic_delimiter@@

    D2 Prompt Selector is, at heart, a clicky panel: you press a "PS" button in the corner of ComfyUI, and a window pops up full of prompt buttons you've saved. Click one and it types into the last textbox you touched. That's genuinely handy for anime tag hoarders, but it has a ceiling - it only helps you, at the keyboard, one prompt at a time. This node, confusingly named the same as the pack, is the answer to that. It turns your whole saved prompt library into a string-processing function you can wire into any workflow, so the same curated tags can feed a batch, a template, or three different models at once.

    The trick is dead simple: you write tokens in your prompt text, and the node swaps them for the registered prompts it looks up in the pack's YAML files.

    How it works

    Your prompts live as YAML in ComfyUI/custom_nodes/D2-PromptSelector-comfyUI/tags/, structured file → category → name, exactly the same library the panel edits. Each .yml file is a tab in the panel. The node loads those files every time it runs, then does a text search-and-replace:

    • --beautiful-- → the registered prompt named "beautiful", searched across every file and category
    • --bg/quality/beautiful-- → full path: file bg, category quality, name beautiful
    • @@place@@ → the whole category expanded into DynamicPrompt syntax: { nature, stream, rock, wood, | classroom, window, curtain, desk, chair, chalkboard, }

    That last one is the fun part. The @@...@@ form doesn't just paste one prompt - it hands you a DynamicPrompt set, so the sampler picks a variant at each generation. That only randomizes if you have a DynamicPrompt-capable node installed (the README points at adieyal's comfyui-dynamicprompts); without one, you just get the literal { ... } text, which most models will read as garbage. The delimiters exist for a reason: -- and @@ are in heavy use by other extensions, and both are input fields so you can switch to [[...]] or whatever doesn't collide.

    Matching is exact - beautiful won't match beautiful2, and any token containing spaces is skipped. Search follows the file order in tags/__config__.yml's sort list and stops at the first hit.

    The inputs that matter

    • string - the text with tokens in it, e.g. 1girl, --beautiful--, best quality. The only one you'll actually think about.
    • delete_unmatch (default True) - what to do with tokens it can't resolve. True silently removes the token and one adjacent comma; False leaves the raw --whatever-- in the output. Leave it True, but remember it exists when prompts start quietly vanishing from your output.
    • delimiter (default --) and dynamic_delimiter (default @@) - change only if another extension is eating your tokens.

    It outputs a single STRING. That goes into the positive prompt box, a text-concat node, or anywhere else that takes text. Note the node is model-agnostic plumbing: whether a tag list actually does anything is up to your checkpoint, and it does a lot more on the SDXL/anime lineage than on the newer LLM-encoded models.

    Installing it

    ComfyUI Manager: search "D2 Prompt Selector". Or the manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/da2el-ai/D2-PromptSelector-comfyUI
    

    Then restart ComfyUI. There's no requirements.txt and no model downloads - it only needs yaml, which ComfyUI already ships. On first launch the pack copies a sample library into tags/ so the panel isn't empty; anything you register in the panel is immediately usable in this node.

    Gotchas

    • The node registers through the newer V3 schema (comfy_entrypoint), so on a badly outdated ComfyUI it won't show up at all - update first.
    • New .yml files you drop into tags/ only become searchable tabs once they're listed in __config__.yml's sort.
    • The tags format is flat by design (file → category → name). If you're coming from an older version with deeper nesting, the pack migrates it and backs the originals up - don't panic at the conversion dialog.
    • Because every execute reloads and re-parses the YAML, this node is fine for occasional runs but it's not the tool for a tight loop that needs to swap prompts a thousand times a second.

    Honestly, if you never batch or share workflows, the panel alone is the better half of this pack. But the moment you want your saved prompts driving something automated instead of your mouse, this node is the missing wire - a small, zero-dependency way to stop retyping the same twenty tags.

    CategoryD2/PromptSelector

    Inputs (4)

    NameTypeDefaultDescription
    stringSTRING置換対象の文字列。--file/category/name-- などのトークンを含められる
    delete_unmatchBOOLEANtrue変換できなかったトークンを削除する(隣接カンマも整形)。False で原文のまま残す
    delimiterSTRING--通常変換トークンの囲み記号(開始=終了の同記号)
    dynamic_delimiterSTRING@@DynamicPrompt 変換トークンの囲み記号(開始=終了の同記号)

    Outputs (1)

    NameTypeDescription
    STRINGSTRING