2025-12-22 09:41:10 +09:00
2025-12-19 04:58:10 +09:00
2025-12-19 04:58:10 +09:00
2026-02-11 16:31:31 +00:00
2026-01-20 03:06:03 +00:00
2025-12-19 04:58:10 +09:00
2026-02-11 16:31:13 +00:00

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__ dress → a 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

  1. Organize wildcards in subfolders - Use __folder/filename__ syntax
  2. Chain expansions - __style__ portrait of __character__ wearing __outfit__
  3. Combine with ControlNet - Vary prompts while maintaining pose/composition
  4. Batch generation - Same seed = same expansion for A/B testing

📄 License

MIT License

S
Description
No description provided
Readme
257 KiB
Languages
Python 100%