Nodes/ComfyUI-Danbooru-Gallery/提示词清洁女仆 (Prompt Cleaning Maid)
ComfyUI Node

提示词清洁女仆 (Prompt Cleaning Maid)

Tidy up messy, copy-pasted tag strings before they hit your encoder

By Aaalice233·Created 11 months ago·Updated 24 days ago· 224
提示词清洁女仆 (Prompt Cleaning Maid)
    • string
    string
    清理逗号 (cleanup_commas)true
    清理空白 (cleanup_whitespace)true
    移除LoRA标签 (remove_lora_tags)false
    清理换行 (cleanup_newlines)否 (false)
    修复括号 (fix_brackets)两者 (both)
    提示词格式化 (prompt_formatting)true
    下划线转空格 (underscore_to_space)true
    权重语法补全 (complete_weight_syntax)true
    智能括号转义 (smart_bracket_escaping)true
    标准化逗号 (standardize_commas)true
    修复分区语法 (fix_region_syntax)true

    If you prompt anime/Danbooru-lineage models, your tag strings are rarely clean by the time they reach your text encoder - pasted from a booru post, glued together from a gallery node and a hand-typed prefix, run through a feature-swap or multi-character tool. Underscores where you want spaces, doubled commas from a botched concatenation, malformed weight syntax, brackets that don't match. Prompt Cleaning Maid is a one-node laundromat for exactly that mess, with ten independent toggles covering the specific failure modes that actually show up in Danbooru-style prompting.

    Why this node earns its keep

    Danbooru's tag vocabulary is the de facto prompting language for the whole Illustrious/NoobAI/Pony family of models - but it's a vocabulary built for a tagging database, not for typed-out prompts, which is exactly where the friction comes from. Tags use underscores (long_hair, not "long hair"), weight syntax like (tag:1.3) is easy to leave malformed if you're editing by hand, and once you're combining strings from multiple sources - a gallery pull, a saved prefix, a character-swap output - stray commas and mismatched brackets creep in fast. This node bundles fixes for all of that into toggles you flip once and forget.

    The inputs and outputs that matter

    One required input carries the string you're cleaning: string. Everything else is a toggle controlling one specific cleanup rule, all sensible-defaulted so the node does something useful out of the box:

    • Comma and whitespace hygiene - cleanup_commas (on by default) removes redundant commas where nothing sits between two of them; cleanup_whitespace (on) trims leading/trailing and doubled-up spaces; standardize_commas (on) normalizes everything to , (comma-space) format.
    • Underscore-to-space - underscore_to_space (on) turns Danbooru's _-joined tags into readable phrases.
    • Weight syntax repair - complete_weight_syntax (on) wraps malformed weight expressions in parentheses, e.g. tag:1.2 becomes (tag:1.2).
    • Bracket handling - fix_brackets (default: both) strips unmatched parentheses and/or square brackets; smart_bracket_escaping (on) tries to tell weight-syntax brackets apart from brackets that are actually part of a character or series name, and flags likely missing commas along the way. fix_region_syntax (on) specifically repairs mismatched brackets in regional-prompt syntax markers like MASK, COUPLE, or FEATHER - worth knowing if you're feeding this cleaner a prompt generated by this pack's own Multi Character Editor, since that's exactly the kind of bracket-heavy syntax it's built to protect from breaking a downstream parser.
    • prompt_formatting (on) reads as the master switch bundling the underscore, weight-syntax, and bracket-escaping cluster together - its own tooltip describes doing all three at once. Where the schema doesn't spell out precedence explicitly, treat it as the umbrella and the individually-named toggles as the fine controls underneath it.
    • cleanup_newlines (default: off) is the one toggle that isn't on by default - choose to replace line breaks with a space or a comma, or leave them alone.
    • remove_lora_tags (default: off, also opt-in) strips LoRA syntax out of the string entirely - useful if you're repurposing a prompt for display or metadata and don't want the LoRA call syntax showing up in it.

    Output: a single cleaned string, ready for your text encoder.

    How to install it

    ComfyUI Manager: search "ComfyUI-Danbooru-Gallery", install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Aaalice233/ComfyUI-Danbooru-Gallery.git
    cd ComfyUI-Danbooru-Gallery
    pip install -r requirements.txt
    

    Restart ComfyUI. Pure text processing - no model downloads.

    Common issues & troubleshooting

    Underscores you wanted kept got turned into spaces. underscore_to_space is on by default and applies broadly - if you have deliberate underscore-joined terms you don't want touched (a specific model or LoRA trigger word, say), turn this off, or clean the string before adding that term.

    LoRA syntax vanished unexpectedly. Check remove_lora_tags - it's off by default, so if it's stripping LoRA calls you actually wanted, something flipped it on, or you're looking at a different string than you think.

    A regional-prompt syntax string (from Multi Character Editor or similar) parses wrong after cleaning. fix_region_syntax is meant to protect exactly this kind of bracket-heavy syntax, but if the syntax convention it expects (MASK, COUPLE, FEATHER) doesn't match what your specific downstream regional-prompting node actually uses, turn this toggle off for that particular string rather than fighting it.

    Node doesn't appear in the menu. Standard pack-load check: confirm the repo path, confirm dependencies installed, check the ComfyUI console at startup for an import error.

    Categorydanbooru

    Inputs (12)

    NameTypeDefaultDescription
    stringSTRING
    清理逗号 (cleanup_commas)BOOLEANtrue清理多余的逗号(如果两个逗号之间没有标签)
    清理空白 (cleanup_whitespace)BOOLEANtrue清理首尾空白和多余的空白字符
    移除LoRA标签 (remove_lora_tags)BOOLEANfalse完全移除字符串中的 LoRA 标签
    清理换行 (cleanup_newlines)COMBO否 (false)将换行符 (\n) 替换为空格或逗号
    修复括号 (fix_brackets)COMBO两者 (both)移除不匹配的括号
    提示词格式化 (prompt_formatting)BOOLEANtrue启用完整的提示词格式化:下划线转空格、权重语法补全、智能括号转义、漏逗号检测等
    下划线转空格 (underscore_to_space)BOOLEANtrue将下划线转换为空格
    权重语法补全 (complete_weight_syntax)BOOLEANtrue为不合规的权重语法添加括号,如 tag:1.2 → (tag:1.2)
    智能括号转义 (smart_bracket_escaping)BOOLEANtrue智能转义括号,区分权重语法和角色系列名称,并检测漏逗号情况
    标准化逗号 (standardize_commas)BOOLEANtrue将逗号标准化为英文逗号+空格格式
    修复分区语法 (fix_region_syntax)BOOLEANtrue自动修复分区语法中的括号不匹配问题(如 MASK、COUPLE、FEATHER 等),防止解析器进入无限循环

    Outputs (1)

    NameTypeDescription
    stringSTRING