ComfyUI Expert Wildcard Prompt
AST-based prompt parser with inline negative routing, smart percentage wildcards, and visual debugging
Expert Text Prompt for ComfyUI
A powerful ComfyUI custom node featuring AST-based prompt parsing, advanced wildcards, probabilistic weighting, skip chances, prompt grouping, dual positive/negative outputs, inline negative extraction (-), $negative placeholder injection, and inline Mute/Solo controls.
Features
- Advanced Wildcards:
{option1 | option2 | option3}with full support for nested wildcards.- Equal Chances:
{red | blue | green}assigns an equal chance to each option. - Weighted Chances:
{70% blue | 30% green}sets explicit relative probabilities.
- Equal Chances:
- Skip Chance (Optional Blocks):
{20%? optional sunglasses, leather jacket, red hat}(20% chance to skip the ENTIRE block completely). - Prompt Grouping (
[GRP:NAME]): Structure large prompts. Groups can be redefined/overwritten ([GRP:NAME]), appended to ([+GRP:NAME]), killed (-[GRP:NAME]), muted (//[GRP:NAME]) or set to solo (![GRP:NAME]). - Inline Mute (
//): Disable specific tags or entire prompt groups without deleting them. Multiple//tags can be used simultaneously. - Inline Solo (
!): Isolate specific tags or groups, ignoring all non-solo elements. Multiple!tags can be used to keep a specific set of tags active. - Quadruple Outputs (
positive,negative,combinations&debug_info): Generates positive and negative strings, outputs live combination counts (INT), and provides adebug_info(STRING) pin displaying visual syntax error diagnostics with^pointers. - Inline Negative Extraction & Subtractive Filtering (
-): Prefix any tag or wildcard option with-(e.g.,-sunglasses,-umbrella). This routes the tag into thenegativeoutput AND acts as a smart filter, actively removing any positive tags that contain this exact word! $negativePlaceholder Injection: Insert$negativeinto your negative prompt field to specify the exact location where extracted-tags are injected.- Flexible Negative Modes:
auto (use $negative): Injects extracted tags into the$negativeplaceholder if present, otherwise prepends them.prepend: Places extracted negative tags at the very start.append: Appends extracted negative tags at the very end.replace: Overwrites the negative prompt field completely.
- Number Range Wildcards (
{MIN-MAX:STEP}):{18-50}randomly selects a number in range. Supports optional steps like{0-10:2}(chooses from0, 2, 4, 6, 8, 10). - SDXL Weights & LoRAs: Native preservation of
(tag:1.2)weights and<lora:name:1.0>tags. - Deterministic Seed: Reproducible wildcard resolution based on input seed.
Installation
Option 1: Via Comfy Registry (CLI)
comfy node install comfyui-expert-wildcard-prompt
Option 2: Via ComfyUI Nodes Manager (UI)
Search for ComfyUI Expert Wildcard Prompt in the ComfyUI Nodes Manager / Extension Installer and click Install.
Option 3: Manual Git Clone
Navigate to your ComfyUI custom_nodes directory:
cd ComfyUI/custom_nodes
git clone https://github.com/v3rm1ll1on/ComfyUI-Expert-Wildcard-Prompt.git
Restart ComfyUI afterward.
Finding the Node in ComfyUI
- Node Name:
Expert Text Prompt (Wildcards & AST) - Category:
prompt/expert
Full Syntax Reference (Cheat Sheet)
| Feature | Syntax Example | Description |
| :--- | :--- | :--- |
| Basic Wildcard | {red \| blue \| green} | Pick one option randomly with equal chance. |
| Weighted Wildcard | {70% blue \| 20% green \| 10% red} | Assign custom percentage probabilities per option. |
| Skip Chance (Optional) | {20%? sunglasses} | 20% chance to omit tag completely (80% chance to include). |
| Number Range | {18-50} | Random integer between min (18) and max (50). |
| Number Range with Step | {1980-2020:5} | Pick random integer with step (1980, 1985, ..., 2020). |
| Nested Wildcards | {60% female, {70% armor \| 30% suit} \| 40% male} | Multi-level wildcard nesting with combined probabilities. |
| Inline Mute Tag | // leather jacket | Temporarily deactivates tag without deleting it. |
| Inline Solo Tag | ! red dress | Isolates marked tags. Non-solo tags are ignored. |
| Prompt Group | [GRP:NAME], tag1, tag2 | Groups tags into a structured, manageable block. Redefining it later overwrites the group. |
| Append to Group | [+GRP:NAME], tag3 | Appends tags to an existing group without overwriting it. |
| Kill / Mute Group | -[GRP:NAME] or //[GRP:NAME] | Completely clears the group from positive output (Mute) and optionally routes to negative (Kill). |
| Inline Negative Extraction | -fish | Routes tag to negative output AND actively removes any positive tags containing the exact word "fish" (e.g. removes "green fish" but keeps "starfish"). |
| Negative Placeholder | $negative | Specifies exact insertion point for - tags in negative_prompt. |
| SDXL Weights & LoRAs | (masterpiece:1.2), <lora:name:1.0> | Preserves weight syntax and LoRA tags natively. |
Usage Examples & Templates
We provide a dedicated examples/ directory with detailed Markdown templates ordered from beginner to masterclass:
| Example File | Topic & Level | Description |
| :--- | :--- | :--- |
| 01_basic_wildcard.md | Beginner | Step-by-step introduction from single wildcards to nested wildcard structures. |
| 02_intermediate_groups_and_weights.md | Intermediate | Percentage weighting (70%), skip chances (20%?), and introducing groups ([GRP:]). |
| 03_advanced_pony_v6_template.md | Advanced | Specialized templates for Pony Diffusion V6 with score groups & anime styles. |
| 04_expert_photorealistic_dual_prompt.md | Expert | Photorealistic templates combining - negative extraction and $negative. |
| 05_mute_and_solo_indepth.md | In-Depth Guide | Tag-level and group-level Mute (//) & Solo (!) isolation workflows. |
| 06_nested_wildcards_indepth.md | In-Depth Guide | 2-Level and 3-Level wildcard nesting in plain text and group contexts. |
| 07_masterclass_character_generator.md | Masterclass | Full production template for multi-ethnic, hyper-realistic character generation. |
Quick Syntax Summary
1. Basic Wildcards
Randomly choose between simple options with equal probability:
a photo of a {cat | dog | fox} sitting on a bench
2. Weighted Chances & Smart Weight Balancing
Explicitly set selection probabilities or mix weighted and unweighted options:
a photo of a girl with {70% blue eyes | 20% green eyes | 10% brown eyes}
How Smart Weight Balancing Works:
You don't need to manually calculate probabilities so everything sums to 100%. The node automatically balances weights intelligently:
-
1. Automatic Leftover Distribution (Partial Weights) If you only weight some options, the remaining percentage is split equally among unweighted options:
{50% red | 30% green | black | white}red(explicit): 50%green(explicit): 30%- Explicit sum = 80%. Remaining budget = 20%.
black&whitesplit leftover 20% equally $\rightarrow$ 10% each.- Final Odds:
red: 50% |green: 30% |black: 10% |white: 10%.
-
2. Over-Commitment Graceful Fallback (Sum > 100%) If your explicit weights exceed 100%:
{50% red | 30% green | black | 50% white}- Unweighted tags (
black) automatically receive a baseline fair share ($100% / N_{\text{total}} = 25%$). - Relative proportions are preserved smoothly without ignoring any option.
- Unweighted tags (
-
3. Zero-Sum Safety Guard If all options are set to 0% (
{0% red | 0% green}), the node automatically falls back to equal distribution (50%/50%) instead of crashing.
[!WARNING] Weights (
XX%) vs. Skip Chance (XX%?) Do not confuse probability weights with skip chances! If you want an option to appear rarely (e.g. 5%), use a normal weight:{blonde | 5% brunette | black | red}. The?syntax (e.g.{80%? ...}) is EXCLUSIVELY used at the very start of a wildcard to skip the entire block, yielding an empty string. If you place a?inside an option list, it will just be parsed as a normal weight.
3. Skip Chance (Optional Blocks)
Add optional elements with a percentage chance of skipping:
portrait of a woman, {20%? glowing neon face tattoos, multiple piercings, dark makeup}
(20% chance to omit all of these tags entirely, 80% chance to include the whole block).
4. Number Range Wildcards ({MIN-MAX:STEP})
Generate random numeric values across a range with optional step increments:
a photo of a {18-50} yo woman born in {1980-2020:5}
(Chooses an age between 18 and 50, and a year from [1980, 1985, 1990, ..., 2020]).
5. Mute & Solo Controls (// & !)
Temporarily disable or isolate tags without editing your prompt text:
- Mute (
//): Deactivates specific tags (supports multiple//in one prompt):masterpiece, // ruined background, leather jacket, // blurry lines - Solo (
!): Isolates only marked tags (supports multiple!tags):
(Resulting output:! red dress, blue shoes, ! golden necklacered dress, golden necklace)
5. Nested Wildcards & Probabilities
Combine multiple levels of wildcards for complex variation:
a {60% female warrior with {70% knight armor | 30% cyber suit} | 40% cyberpunk rogue}
6. Dynamic Prompt Grouping ([GRP:NAME], [+GRP:NAME], -[GRP:NAME])
Structure large prompts into organized blocks that can be dynamically manipulated anywhere, even inside wildcards!
- Overwrite (
[GRP:NAME]): Clears any previous tags for this group and starts fresh. - Append (
[+GRP:NAME]): Adds tags to the existing group without deleting old ones. - Kill / Mute (
-[GRP:NAME]///[GRP:NAME]): Completely removes the entire group from the positive output.
[GRP:EXPRESSION], happy, smiling
[GRP:ACTION],
{
[GRP:POSE1], standing around, [+GRP:EXPRESSION], laughing
|
[GRP:POSE2], running away, [GRP:EXPRESSION], exhausted, sweaty
|
[GRP:POSE3], jumping, -[GRP:EXPRESSION]
}
(If POSE1 is rolled, EXPRESSION becomes happy, smiling, laughing. If POSE2 is rolled, EXPRESSION is overwritten to just exhausted, sweaty. If POSE3 is rolled, EXPRESSION is completely deleted!)
7. Expert Dual-Prompting & Subtractive Filtering (- & $negative)
Combine positive wildcards, automatic negative extraction, and custom negative templates in one go. The - tag also acts as an active subtractive filter for your positive prompt using whole-word matching.
positive_prompt:
[GRP:CHARACTER], portrait of a young woman, {70% sunny day, -sunglasses | 30% rainy day, -umbrella}, leather jacket, green umbrella
negative_prompt:
(3d render, cgi, plastic skin:1.3), $negative, (deformed hands:1.2), blurry
Output Results:
- If
sunny dayis selected by the seed:positive:portrait of a young woman, sunny day, leather jacket, green umbrellanegative:(3d render, cgi, plastic skin:1.3), sunglasses, (deformed hands:1.2), blurry
- If
rainy dayis selected by the seed:positive:portrait of a young woman, rainy day, leather jacket(Notice howgreen umbrellais actively deleted from the positive prompt because of-umbrella!)negative:(3d render, cgi, plastic skin:1.3), umbrella, (deformed hands:1.2), blurry
Node Parameters & Outputs
- Inputs:
positive_prompt: Main prompt text supporting wildcards, Mute/Solo, weights, and-negative tags.negative_prompt: Secondary prompt field supporting the$negativeplaceholder.negative_mode: Options:auto (use $negative),prepend,append,replace.seed: Random seed for reproducible wildcard selections.
- Outputs:
positive: Connects toCLIP Text Encode (Positive).negative: Connects toCLIP Text Encode (Negative).
License
MIT