ComfyUI-Wildcards-rework

ComfyUI-Wildcards-rework
★ 2

提示词扩展权重选择多选与范围嵌套与自定义分隔
用于在ComfyUI中通过通配符与花括号表达式动态生成提示词,支持加权、批量/范围选择、多选、自定义分隔与嵌套扩展,实现无限变体与可控随机。
💡 为ComfyUI提示词生成大量可控随机变体,提升创作多样性。
🍴 1 Forks💻 Python🔄 2026-02-11
📦
网盘下载
复制链接后前往夸克网盘下载
https://pan.quark.cn/s/e00a65475347
📦 requirements.txt
chardet
📄 README

ComfyUI_Randomizer

A powerful ComfyUI custom node for dynamic prompt generation using wildcards and bracket expressions. Create infinite variations from template prompts with weighted selection, multi-picks, and nested expansions.


✨ Features

| Feature | Syntax | Example |

|———|——–|———|

| Wildcard Expansion | __name__ | a __colors__ dressa red dress |

| Random Selection | {a\|b\|c} | {red\|blue\|green}blue |

| Weighted Choice | option$weight | {rare$1\|common$10}common (10× more likely) |

| Multi-Pick | {N$$a\|b\|c} | {2$$red\|blue\|green\|yellow}red, yellow |

| Range Pick | {N-M$$a\|b\|c} | {1-3$$a\|b\|c\|d}b, d |

| Custom Separator | {N$$sep$$...} | {2$$ and $$a\|b\|c}a and c |

| Nested Expansion | {a\|{b\|c}} | Full recursive support |

| History Recall | __name[0]__ | __gname__ ... __gname[0]__ → repeats last pick |


🔧 Installation

cd ComfyUI/custom_nodes

git clone <repository-url> ComfyUI_Randomizer

# Restart ComfyUI - dependencies install automatically

Dependencies: chardet (auto-installed)


📦 Node: Text Wildcards

Category: Randomizer

Inputs

| Input | Type | Description |

|——-|——|————-|

| text | STRING | Prompt template with wildcards/brackets |

| seed | INT | Random seed for reproducibility |

| refresh | INT | Set to 1 to reload wildcard files |

| n_keep_history | INT | Keep last N results per wildcard for __name[0]__ recall |

Outputs

| Output | Type | Description |

|——–|——|————-|

| text | STRING | Expanded prompt |

| ascii_text | STRING | ASCII-safe version (non-ASCII replaced) |


📂 Wildcards Directory

Place .txt files in the wildcards/ folder. Each line becomes a selectable option.

Example: wildcards/colors.txt

red

blue

green

yellow$3    # 3× more likely to be selected

Usage in Prompt

a beautiful __colors__ sunset over __places__

Expands to: a beautiful yellow sunset over mountain lake


📖 Syntax Reference

Basic Selection

# Random from wildcard file

__filename__


# Random from inline options  

{option1|option2|option3}

History Recall

# After expanding __gname__ at least once, recall recent results:
__gname[0]__   # most recent
__gname[1]__   # previous

Weighted Selection

# Weight with $N suffix (higher = more likely)

{rare_item$1|common_item$5|very_common$20}

Multi-Pick

# Pick exactly 2 items

{2$$red|blue|green|yellow}

→ "red, green"



# Pick 1-3 items randomly  

{1-3$$apple|banana|cherry|date}

→ "banana, date"



# Custom separator

{2$$ and $$cats|dogs|birds}

→ "cats and birds"

Nested Expressions

# Wildcards can reference other wildcards

# In colors.txt:

{basic|__special_colors__}



# Bracket groups can nest

{{red|blue}|{green|yellow}}


🎨 Advanced Tips

  • Organize wildcards in subfolders – Use __folder/filename__ syntax
  • Chain expansions__style__ portrait of __character__ wearing __outfit__
  • Combine with ControlNet – Vary prompts while maintaining pose/composition
  • Batch generation – Same seed = same expansion for A/B testing

  • 📄 License

    MIT License