Codex is a visual wildcard manager and gallery system for Stable Diffusion. It solves the problem of managing thousands of text prompts by providing a visual card-based interface.
Key Capabilities:
- 🖼️ Visual Browser: Organize wildcards as cards in the Extra Networks panel.
- ⚡ One-Click Insertion: Click a card to insert the wildcard path directly into your prompt.
- 🎲 Advanced Engine: Native support for standard wildcards, variants (
{a|b}), and sampling. - 📸 Preview System: Generate preview images to see exactly what a wildcard produces before you use it.
- 🔧 Zero Dependencies: Works out of the box. No other extensions required.
- Open Stable Diffusion WebUI.
- Go to Extensions → Install from URL.
- Paste this repository URL.
- Click Install.
- Restart the WebUI completely.
Clone the repo into your extensions folder:
git clone https://github.com/SiliconeShojo/Codex.gitCodex uses its own internal directory for wildcards.
Location: extensions/codex/wildcards/
📂 1. File Formats (Click to expand)
You can use simple .txt files or structured .yaml files.
Create extensions/codex/wildcards/characters/heroes.txt:
# This is a comment
a brave knight in shining armor
a mysterious wizard
a cyberpunk netrunner
Usage: __characters/heroes__
Create extensions/codex/wildcards/styles.yaml:
artistic:
oil:
- thick impasto oil painting
- classical oil portrait
watercolor:
- soft watercolor style
- wet-on-wet techniqueUsage: __styles/artistic/oil__
🎲 2. Dynamic Syntax Guide (Click to expand)
Codex features a built-in parser for advanced prompting logic.
| Type | Syntax | Result |
|---|---|---|
| Standard | __filename__ |
Picks 1 random line from a .txt file or .yaml category. |
| Variants | {red|blue|green} |
Randomly chooses one option (e.g., "red"). |
| Sampling | __3$$colors__ |
Picks 3 unique entries, joined by the default , . |
| Sampling | __5$$|$$adjectives__ |
Picks 5 entries, joined by a custom separator |. |
| Nested | __meta_wildcard__ |
Wildcards inside wildcards are automatically resolved. |
Avoid extra spaces: The parser is space-sensitive. Use
__3$$colors__rather than__3$$ colors__to ensure the name matches your local wildcard files or YAML keys exactly.
- Navigate to the Extra Networks panel (where Lora/Checkpoints are).
- Click the "Codex" tab.
- Clicking a card inserts the syntax (e.g.,
__wildcard__) into your prompt.
Make your gallery beautiful by generating preview images for your text files.
- Go to txt2img.
- Open the "Codex Preview Manager" script in the scripts dropdown.
- Select Wildcards: Use the dropdown or path selector to choose files.
- Insertion Method:
- AFTER/BEFORE: Appends wildcard to current prompt.
- SEARCH & REPLACE: Replaces specific text with the wildcard.
- Click Generate.
Wildcards not showing?
- Ensure files are in
extensions/codex/wildcards/. - Ensure file extensions are
.txtor.yaml. - Check the console for
[Codex]indexing logs.
Previews not generating?
- Verify the "Codex Preview Manager" script is active.
- Ensure you have selected a wildcard in the script dropdown.
Wildcards not replacing in generation?
- Check "Enable Wildcard Replacement" in the Codex accordion.
- Verify the wildcard name matches the filename exactly.
This project builds upon the excellent work of:
- navimixu/wildcard-gallery — Original wildcard gallery concept and foundation for this fork.
- adieyal/sd-dynamic-prompts — Advanced prompt parsing logic and dynamic syntax engine that powers Codex's variant and sampling features.
Special thanks to both projects for their innovative approaches to prompt management in Stable Diffusion.
Changelog
-
UI/UX layout improvements:
- Implemented adaptive layout toggling: when the "Use Wildcard Branch Selector" checkbox is checked, the individual "Wildcards" dropdown automatically hides itself to maintain a clean workspace.
- Converted the root input textarea into a dynamic Dropdown choice list that parses and lists root folders automatically.
-
Thread-safety & Concurrency:
- Implemented an atomic dictionary state swap during wildcard indexing walks, preventing file-access collisions ("Access is denied") under concurrent threads.
- Added a safe NoneType fallback check when the branch selector is inactive.
-
Performance & VRAM optimization:
- Integrated PyTorch active GPU memory garbage collection between preview generation batches.
- Configured auto-downscaling of newly generated preview images to 512px.
- Added a generator-based script workflow to optimize and resize existing card previews.
- Removed heavy, high-overhead 3D CSS perspective transforms and animated backgrounds.