chardet
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.
| 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 |
cd ComfyUI/custom_nodes
git clone <repository-url> ComfyUI_Randomizer
# Restart ComfyUI - dependencies install automatically
Dependencies: chardet (auto-installed)
Category: Randomizer
| 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 |
| Output | Type | Description |
|——–|——|————-|
| text | STRING | Expanded prompt |
| ascii_text | STRING | ASCII-safe version (non-ASCII replaced) |
Place .txt files in the wildcards/ folder. Each line becomes a selectable option.
wildcards/colors.txtred
blue
green
yellow$3 # 3× more likely to be selected
a beautiful __colors__ sunset over __places__
Expands to: a beautiful yellow sunset over mountain lake
# Random from wildcard file
__filename__
# Random from inline options
{option1|option2|option3}
# After expanding __gname__ at least once, recall recent results:
__gname[0]__ # most recent
__gname[1]__ # previous
# Weight with $N suffix (higher = more likely)
{rare_item$1|common_item$5|very_common$20}
# 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"
# Wildcards can reference other wildcards
# In colors.txt:
{basic|__special_colors__}
# Bracket groups can nest
{{red|blue}|{green|yellow}}
__folder/filename__ syntax__style__ portrait of __character__ wearing __outfit__MIT License