ComfyUI Prompt Manager
!License !Python !ComfyUI !Tests !Code Quality
A comprehensive ComfyUI custom node that extends the standard text encoder with persistent prompt storage, advanced search capabilities, automatic image gallery system, folder-based organization, LoRA Manager integration, and powerful ComfyUI workflow metadata analysis using SQLite.
Overview
ComfyUI Prompt Manager provides two powerful node types for comprehensive prompt management:
PromptManager (CLIP Encoding Node)
A drop-in replacement for ComfyUI's standard CLIPTextEncode node with database features:
- 🔄 Drop-in Replacement: Works exactly like the standard text encoder
- 🤖 CLIP Encoding: Outputs CONDITIONING for use with samplers and other CLIP-dependent nodes
PromptManagerText (Text-Only Node)
A text-focused variant that outputs raw STRING for maximum flexibility:
- 📝 Pure Text Output: Outputs STRING type for use with any text-accepting node
- 🔗 Text Concatenation: Built-in prepend/append functionality for dynamic text assembly
- ⚡ Lightweight Processing: No CLIP encoding overhead for text-only workflows
PromptSearchList (Batch Processing Node)
A search node that outputs prompts as a list for batch processing workflows:
- 🔍 Database Search: Search prompts by text, category, tags, and rating
- 📋 List Output: Uses
OUTPUT_IS_LISTfor native batch processing support - 🔗 Batch Compatible: Connect directly to batch processing nodes like String OutputList
- ⚡ Read-Only: Lightweight search operation without database writes
Shared Features
Both nodes include the complete PromptManager feature set:
- 💾 Persistent Storage: Automatically saves all prompts to a local SQLite database
- 🔍 Advanced Search: Query past prompts with text search, category filtering, and metadata
- 📁 Folder Filter: Browse and filter prompts by output subdirectory
- 🖼️ Automatic Image Gallery: Automatically links generated images to their prompts
- 🏷️ Rich Metadata: Add categories, tags, ratings, notes, and workflow names to prompts
- 🚫 Duplicate Prevention: Uses SHA256 hashing to detect and prevent duplicate storage
- 🌐 Advanced Web Interface: Comprehensive admin dashboard with metadata analysis
- 📊 Analytics: Track prompt usage patterns and effectiveness over time
- 🔬 Workflow Analysis: Extract and analyze ComfyUI workflow data from PNG images
- 📋 Metadata Viewer: Standalone tool for analyzing ComfyUI-generated images
- 🛠️ System Management: Built-in diagnostics, backup/restore, and maintenance tools
- 🏷️ AI AutoTag: Automatically tag your image collection using WD14 or JoyCaption vision models
- 🔗 LoRA Manager Integration: Import LoRA metadata and preview images from ComfyUI-Lora-Manager
Features
Core Functionality
PromptManager (CLIP Encoding)
- Text Encoding: Standard CLIP text encoding for ComfyUI workflows
- Conditioning Output: Produces CONDITIONING for samplers and generation nodes
- Full Compatibility: Drop-in replacement for CLIPTextEncode nodes
PromptManagerText (Text-Only)
- String Output: Produces STRING for use with any text-accepting node
- Text Concatenation: Prepend and append fields for dynamic text assembly
- Lightweight: No CLIP encoding overhead for pure text workflows
- Flexible Integration: Works with custom nodes, text processors, and other STRING inputs
Shared Features
- Auto-Save: Every prompt is automatically saved to the database
- Metadata Support: Optional categories, tags, ratings (1-5), notes, and workflow names
- Hash-based Deduplication: Prevents storing identical prompts multiple times
🖼️ Advanced Gallery with Full Media Support
The comprehensive gallery system provides complete management of all ComfyUI output with professional viewing capabilities:
📁 Output-Wide Gallery Mode
- Complete Output Monitoring: Automatically scans and displays ALL content from your ComfyUI output directory
- Multi-Format Support: Handles images (.png, .jpg, .jpeg, .webp, .gif) and videos (.mp4, .webm, .avi, .mov, .mkv, .m4v, .wmv)
- Intelligent Organization: View all generated content regardless of which workflow created it
- Advanced Filtering: Filter by media type, date range, file size, and generation parameters
- Performance Optimized: Efficient scanning with thumbnail generation and lazy loading
🎬 Full Video Support
- Native Video Playback: HTML5 video player with custom controls for all supported formats
- Video Thumbnails: Automatic thumbnail generation with OpenCV, ffmpeg, or placeholder fallback
- Playback Controls: Autoplay, mute, loop settings with persistent preferences
- Video Navigation: Seamless navigation between videos with keyboard shortcuts
- Video Metadata: Display duration, resolution, aspect ratio, and file information
- Mixed Media Gallery: Videos and images integrated seamlessly in the same interface
🔍 Professional Image Viewer (ViewerJS Integration)
- Full-Featured Viewing: Zoom, rotation, slideshow modes with professional controls
- Advanced Navigation: Smooth transitions, thumbnail strip, and keyboard shortcuts
- Zoom Controls: Mouse wheel zoom, drag to pan, and touch gesture support
- Toolbar Features: Comprehensive toolbar with zoom, rotate, flip, reset, and fullscreen
- Dark Theme Integration: Seamless styling that matches the admin interface
🔬 Advanced Metadata Analysis
- Real-time PNG Parsing: Extract ComfyUI workflow data from any generated image
- Integrated Metadata Panel: Live workflow analysis with copy functionality
- Generation Parameters: CFG scale, steps, sampler, seed, and model information
- One-click Copying: Copy prompts, parameters, and workflow data directly
- File Path Integration: Direct access to files in your output directory
- Cross-Platform Support: Works on desktop, tablet, and mobile devices
⚡ Performance Features
- Smart Thumbnail System: Generates optimized thumbnails for faster loading
- Lazy Loading: Load content as needed for smooth browsing of large galleries
- Grid & List Views: Choose between compact grid or detailed list display
- Pagination: Efficient browsing of thousands of generated files
- Search & Filter: Real-time search across filenames and metadata
Viewer.js is vendored locally. See Viewer.js maintenance for reproducible updates, verification, and automated update PRs.
Prompt Manager appears as Prompt Manager (Classic) in the Add Node menu. It keeps the existing layout and behavior while using shared ComfyAssets Toolkit controls that follow ComfyUI's light/dark theme. Existing workflows keep the same internal node identifier and sockets. The reusable architecture is inspired by Pixaroma; no implementation or assets were copied. See the toolkit maintenance notes.
Prompt Manager (Focused) adds an editor-first layout with collapsible
composition and metadata fields. Open Browse library to search saved prompts,
filter by saved category and comma-separated tags, preview a selection, then choose
Use prompt; Load metadata controls whether
category and tags come with it. Metadata fields suggest saved categories and tags;
choose with the mouse or arrow keys and Enter. Tag selections append , for the
next tag; category remains a single value. New values can still be typed freely.
Prepend and append STRING sockets remain visible
when the fields are collapsed, so LoRA trigger outputs can connect directly.
Encoding, storage, and CONDITIONING/text outputs match Classic. Both layouts
support ComfyUI Classic and Nodes 2.0.
Prompt Manager (Split) keeps the same editor and library visible together. Wide nodes place the library beside the editor; narrow nodes stack the panels. It shares Focused's category/tag autocomplete, search filters, preview-before-use, workflow persistence, and connectable prepend/append inputs. Encoding and storage match Classic and Focused.
🔬 ComfyUI Workflow Analysis
- PNG Metadata Parsing: Advanced PNG chunk analysis to extract embedded ComfyUI data
- Workflow Data Extraction: Complete ComfyUI workflow JSON recovery from images
- Prompt Recovery: Extract positive/negative prompts from any ComfyUI-generated image
- Generation Parameters: Recover steps, CFG scale, sampler, seed, and model information
- Multi-Node Support: Handles PromptManager, CLIPTextEncode, and other node types
- Copy & Export: One-click copying of prompts and workflow JSON download
- Standalone Viewer: Dedicated metadata analysis tool at
/prompt_manager/metadata.html - Drag & Drop Interface: Easy analysis by dropping PNG files directly into the viewer
- Error Handling: Robust parsing with NaN value cleaning and malformed JSON recovery
📋 Standalone Metadata Viewer
- Independent Tool: Access at
http://localhost:8188/prompt_manager/metadata.html - Real-time Analysis: Instant PNG metadata extraction and display
- Comprehensive Display: Shows all discoverable ComfyUI workflow information
- Export Capabilities: Download workflow JSON files for reuse
- File Path Integration: Click to reveal file locations in your system
- Visual Interface: Clean, organized presentation of complex workflow data
Search & Retrieval
- Full-text search across all stored prompts
- Category filtering for organized prompt collections
- Tag-based search with support for multiple tags, with autocomplete that narrows to tags seen together with the ones already typed
- Rating filters to find your best prompts
- Date range filtering for temporal searches
- Recent prompts quick access
- Top-rated prompts for quality discovery
- Image search by file properties and metadata
🌐 Advanced Web Interface
- Admin Dashboard: Comprehensive browser-based management interface with modern dark theme
- Responsive Design: Works on desktop, tablet, and mobile devices
- Real-time Search: Instant search results as you type
- Bulk Operations: Edit multiple prompts simultaneously with batch tools
- Settings Panel: Configure behavior and display options
- System Management: Complete toolset for database operations:
- Export Tools: Download prompts and metadata in various formats
- Progress Tracking: Real-time progress indicators for long operations
- Error Handling: Graceful error display with recovery suggestions
Database Management
- SQLite backend for reliable local storage
- Automatic schema creation and management
- Database optimization with proper indexing and maintenance tools
- Export functionality to JSON or CSV formats
- Backup and restore capabilities
- Relationship tracking between prompts and generated images
- Orphaned prompt cleanup to remove prompts without linked images
Installation
For ComfyUI Users
- Clone the repository into your ComfyUI custom_nodes directory:
cd ComfyUI/custom_nodes/
git clone https://github.com/ComfyAssets/ComfyUI_PromptManager
cd ComfyUI_PromptManager
- Install dependencies:
pip install -r requirements.txt
- Restart ComfyUI to load the new node
- Add the nodes to your workflow:
- Access the web interface:
http://localhost:8188/prompt_manager/admin - Full management interface
- Metadata Viewer: http://localhost:8188/prompt_manager/metadata.html - Standalone PNG analysis tool
- Simple Interface: http://localhost:8188/prompt_manager/ - Basic prompt browser
Prerequisites
- ComfyUI installation
- Python 3.8 or higher
- SQLite3 (included with Python)
watchdoglibrary for automatic image monitoring
Usage
Basic Usage
Using PromptManager (CLIP Encoding)
Replace any CLIPTextEncode node with PromptManager:
- Add the PromptManager node to your workflow
- Connect CLIP model (same as standard text encoder)
- Enter your prompt in the text field
- Connect the CONDITIONING output to your sampler node
Using PromptManagerText (Text-Only)
For text-only workflows or when you need STRING output:
- Add the PromptManagerText node to your workflow
- Enter your prompt in the text field
- Optionally use prepend/append for dynamic text assembly:
- Connect the STRING output to any node that accepts text input
Using PromptSearchList (Batch Processing)
For batch processing workflows that need multiple prompts:
- Add the PromptSearchList node to your workflow
- Configure search filters:
- Connect the prompts output to batch-compatible nodes like String OutputList
- Each matching prompt will be processed as a separate batch item
Shared Metadata Options
Both nodes support the same metadata fields:
- Category: "portraits", "landscapes", "abstract", etc.
- Tags: "detailed, anime, masterpiece" (comma-separated)
- Rating: 1-5 stars for prompt quality (web interface only)
- Notes: Any additional information (web interface only)
- Workflow Name: Name of your workflow for organization (web interface only)
🖼️ Using the Output-Wide Gallery
The comprehensive gallery system provides complete access to all your ComfyUI output:
📁 Accessing the Gallery
- Open the admin interface at
http://localhost:8188/prompt_manager/admin - Click the "🖼️ Gallery" button to open the output-wide gallery
- Browse all content from your ComfyUI output directory
🎬 Video & Image Support
- Mixed Media Viewing: Images and videos appear together in the same gallery
- Video Thumbnails: Videos show with play button overlays and 🎬 icons
- Smart Filtering: Filter by media type (All, Images, Videos) using the dropdown
⚙️ Gallery Settings
Configure your viewing experience in the settings panel:
- Display Settings: Default view, items per page, grid columns, media info, infinite scrolling
- Performance Settings: Image quality, lazy loading
- Video Settings: Autoplay, mute by default, loop videos
- Thumbnail Management: Generate optimized thumbnails for faster loading (runs on the configured worker threads; a run that stops at the per-run cap tells you how many remain)
- Find Duplicate Images: Hashes every file on the worker threads with a progress bar; close the window and it keeps running, results wait in a pill
- Rescan Output Folder: Drops the server-side listing cache and rewalks the folders
🖼️ Image Viewing Experience
- Click any image to open the professional viewer with:
- Use keyboard shortcuts:
🎬 Video Viewing Experience
- Click any video to open the video player with:
- Playback settings are remembered across sessions
🔍 Advanced Features
- Real-time Search: Search across filenames and metadata
- View Modes: Switch between grid and list views
- Sorting Options: Sort by date, size, or filename
- Pagination: Efficiently browse thousands of files
- Thumbnail Generation: Create optimized thumbnails for better performance
🔬 Analyzing ComfyUI Images
Use the standalone metadata viewer to analyze any ComfyUI-generated PNG:
- Open the metadata viewer at
http://localhost:8188/prompt_manager/metadata.html - Drag and drop any PNG file with ComfyUI workflow data
- View extracted information:
- Copy data using the built-in copy buttons
- Export workflow as JSON file for reuse in ComfyUI
📸 Bulk Image Scanning
Import existing ComfyUI images into your database:
- Open admin dashboard and click "📸 Scan Images"
- Start scan to analyze every configured output directory
- Monitor progress with real-time status updates. The scan runs on the server: closing the window only minimizes it to a progress pill, and reloading the page re-attaches to a running scan
- Review results showing:
- Access imported data through the normal gallery interface
ffprobe is installed, the prompt ComfyUI's video savers embed in MP4/MOV/WebM files. Files are read on the number of worker threads set in Settings → Performance (default: half your cores), which makes a large library several times faster.
🏷️ AI AutoTag
Automatically tag your entire image collection using AI vision models:
Model Options
- WD14 SwinV2 / WD14 ViT: Fast ONNX-based classifiers (~400MB) that output Danbooru tags with confidence scores — no prompt needed, adjustable confidence thresholds
- JoyCaption Beta One FP16: Full precision model for highest quality tagging (requires more VRAM)
- JoyCaption Beta One GGUF (FP8): Quantized model for lower VRAM usage with minimal quality loss
Two Tagging Modes
- AutoTag (Batch Mode): Tag your entire collection automatically
- Review Mode: Tag images one-by-one with approval
Handling Existing Tags
For users who have meticulously tagged their collections from the start:
- AutoTag respects your existing work with the "Skip tagged" option
- "auto-scanned" placeholder tags don't count as real tags
- Choose to re-tag specific images while preserving others
- Review mode asks before overwriting on each image
Customization
Adjust the system prompt to match your tagging style:
- Focus on specific attributes (style, mood, composition, subjects)
- Match your existing tag vocabulary
- Optimize for your collection's theme (anime, photography, landscapes, etc.)
Requirements
- Sufficient VRAM for the chosen model (FP16 requires more, GGUF is lighter)
- Models are downloaded automatically on first use
- Feature requests and improvements are welcome!
📁 Folder Filter
Organize and filter your prompt library by output subdirectory. The dashboard search panel includes a Folder dropdown that lists all subdirectories where your images are stored.
- Automatic Detection: Folders are extracted from your image paths — no configuration needed
- Multi-Directory Support: Works across all configured gallery scan directories
- Quick Filtering: Select a folder from the dropdown to instantly filter prompts to that subdirectory
Note: If you have an existing prompt library from before the folder feature was added, you will need to rescan your image library (click Scan Images in the admin dashboard) to populate folder data for your existing prompts.
🔗 LoRA Manager Integration
If you use ComfyUI-Lora-Manager, PromptManager can import your LoRA metadata, trigger words, and example images directly into your prompt database. This lets you search, tag, and browse your LoRA collection alongside your regular prompts.
WIP: LoRA Manager support is a work in progress — this was a highly requested feature. Please open issues for any bugs or feature requests.
Enabling the Integration
- Open the admin dashboard and click Settings
- Scroll to the Integrations section — PromptManager will auto-detect if LoRA Manager is installed
- Toggle the LoraManager switch to enable
- Optionally enable Auto-inject trigger words to automatically append LoRA trigger words when
is detected in your prompts - Click Save Settings (requires a ComfyUI restart to take effect)
Importing LoRA Data
Click Import LoRA Data in the settings panel to start the import. A progress popup shows real-time status as each LoRA is processed:
- Scans all LoRA directories (including
extra_model_paths.yamlpaths) for metadata - Downloads example images from CivitAI as 512px thumbnails
- Creates a prompt entry for each LoRA with trigger words, example prompts, and preview images
- All imported LoRAs are tagged with
lora-managercategory for easy filtering
After import, filter by the lora-manager category to browse your LoRA collection.
CivitAI API Key (Optional)
A CivitAI API key is required if your library contains NSFW LoRAs — CivitAI blocks unauthenticated access to NSFW preview images. Without a key, only SFW preview images are downloaded.
To add your key:
- Get your API key from civitai.com/user/account
- Paste it into the CivitAI API Key field in the Integrations settings
- Save and re-import to download any previously skipped images
Note: Re-importing is safe — PromptManager skips LoRAs that were already imported. To do a fresh import, the previous lora-manager data is cleared automatically before re-scanning.
🌐 Web Interface Features
The comprehensive web interface provides:
- Search Bar: Real-time search across all prompts
- Filter Options: Filter by category, tags, rating, and date
- Bulk Operations: Select multiple prompts for batch editing
- Export Tools: Download your prompt collection
- Settings Panel: Configure auto-save and display options
- Diagnostics: System health checks and troubleshooting
🔧 Database Maintenance
Keep your database optimized with built-in maintenance tools:
- Open the admin dashboard and click "🔧 Maintenance"
- Select maintenance operations:
- Run selected operations and monitor progress in real-time
- Review results showing detailed information about each operation
Database Location
By default, the database is saved as prompts.db in the extension directory. It contains your prompt library and image links. See the database path compatibility note before upgrading a deployment with a custom path.
Searching Prompts
Use the web interface for intuitive searching, or access the database directly:
from database.operations import PromptDatabase
db = PromptDatabase()
Search for landscape prompts
results = db.search_prompts(text="landscape", limit=10)
Find highly rated prompts
results = db.search_prompts(rating_min=4)
Search by category and tags
results = db.search_prompts(
category="portraits",
tags=["anime", "detailed"]
)
Get recent prompts
recent = db.get_recent_prompts(limit=20)
Get images for a prompt
images = db.get_prompt_images(prompt_id="123")
Examples
PromptManager (CLIP Encoding) Examples
Example 1: Basic Prompt Storage
Input: "A beautiful sunset over a mountain lake"
Category: "landscapes"
Tags: "nature, sunset, mountains, water"
→ Outputs: CONDITIONING for sampler nodes
Example 2: Character Prompt
Input: "Portrait of a cyberpunk hacker with neon implants"
Category: "characters"
Tags: "cyberpunk, portrait, sci-fi, neon"
→ Outputs: CONDITIONING for sampler nodes
PromptManagerText (Text-Only) Examples
Example 3: Dynamic Text Assembly
Main Text: "beautiful landscape"
Prepend Text: "masterpiece, ultra detailed,"
Append Text: ", 8k resolution, trending on artstation"
→ Final Output: "masterpiece, ultra detailed, beautiful landscape, 8k resolution, trending on artstation"
Example 4: Text Processing Pipeline
Input: "A serene mountain lake at sunset"
Category: "landscapes"
Tags: "nature, peaceful, golden hour"
→ Outputs: STRING for use with text processors, style nodes, or other custom nodes
Example 5: Multi-Node Text Workflow
PromptManagerText → Text Processor → Style Applicator → Final Text Node
"cyberpunk city" → style processing → "neon-lit cyberpunk metropolis at night"
PromptSearchList (Batch Processing) Examples
Example 6: Batch Processing with Tags
Tags: "anime, detailed"
Limit: 10
→ Outputs: List of up to 10 prompts with both "anime" and "detailed" tags
→ Each prompt is processed as a separate batch item
Example 7: Category-Based Batch
Category: "portraits"
Min Rating: 4
Limit: 20
→ Outputs: List of up to 20 highly-rated portrait prompts for batch generation
Traditional Examples
Example 8: Abstract Art
Input: "Swirling colors in an abstract geometric pattern"
Category: "abstract"
Tags: "geometric, colorful, pattern, modern"
Rating: 3 (set via web interface)
Notes: "Good for experimental art" (set via web interface)
Database Schema
-- Prompts table
CREATE TABLE prompts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
text TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
workflow_name TEXT,
category TEXT,
tags TEXT, -- JSON array of tags
rating INTEGER CHECK(rating >= 1 AND rating <= 5),
notes TEXT,
hash TEXT UNIQUE -- SHA256 hash for deduplication
);
-- Generated images table
CREATE TABLE generated_images (
id INTEGER PRIMARY KEY AUTOINCREMENT,
prompt_id TEXT NOT NULL,
image_path TEXT NOT NULL,
filename TEXT NOT NULL,
generation_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
file_size INTEGER,
width INTEGER,
height INTEGER,
format TEXT,
workflow_data TEXT, -- JSON workflow metadata
prompt_metadata TEXT, -- JSON prompt parameters
parameters TEXT, -- JSON generation parameters
FOREIGN KEY (prompt_id) REFERENCES prompts(id)
);
Architecture
Core Components
prompt_manager.py- Main ComfyUI node implementation (CLIP encoding)prompt_manager_text.py- Text-only node implementation (STRING output)prompt_search_list.py- Batch search node implementation (LIST output)database/models.py- Database schema and connection managementdatabase/operations.py- CRUD operations and search functionalitypy/api/- Web API route modules (prompts, images, tags, lora integration, etc.)py/config.py- Configuration managementpy/lora_utils.py- LoRA Manager integration utilitiesutils/hashing.py- SHA256 hashing for deduplicationutils/validators.py- Input validation and sanitizationutils/image_monitor.py- Automatic image detection systemutils/prompt_tracker.py- Prompt execution trackingutils/metadata_extractor.py- PNG metadata analysis engineutils/logging_config.py- Comprehensive logging systemutils/diagnostics.py- System diagnostics and health checksweb/admin.html- Advanced admin dashboard with metadata panelweb/index.html- Simple web interfaceweb/comfy/prompt_manager.js- ComfyUI canvas extension (the only file ComfyUI loads)web/js/admin.js,web/js/gallery.js- Dashboard and gallery JavaScriptweb/js/tags-page.js- Tag management JavaScriptweb/metadata.html- Standalone PNG metadata viewer
File Structure
ComfyUI_PromptManager/
├── __init__.py # Node registration
├── prompt_manager.py # Main node implementation (CLIP encoding)
├── prompt_manager_text.py # Text-only node implementation (STRING output)
├── prompt_search_list.py # Batch search node implementation (LIST output)
├── database/
│ ├── __init__.py
│ ├── models.py # Database schema
│ └── operations.py # Database operations
├── py/
│ ├── __init__.py
│ ├── api/ # Web API route modules
│ ├── config.py # Configuration
│ └── lora_utils.py # LoRA Manager integration
├── utils/
│ ├── __init__.py
│ ├── hashing.py # Hashing utilities
│ ├── validators.py # Input validation
│ ├── image_monitor.py # Automatic image detection
│ ├── prompt_tracker.py # Prompt execution tracking
│ ├── metadata_extractor.py # PNG metadata analysis
│ ├── logging_config.py # Logging system
│ └── diagnostics.py # System diagnostics
├── web/
│ ├── admin.html # Advanced admin dashboard
│ ├── gallery.html # Image gallery
│ ├── index.html # Simple web interface
│ ├── metadata.html # Standalone metadata viewer
│ ├── comfy/
│ │ └── prompt_manager.js # ComfyUI canvas extension (WEB_DIRECTORY)
│ └── js/
│ ├── admin.js # Dashboard JavaScript
│ ├── gallery.js # Gallery JavaScript
│ └── tags-page.js # Tag management JavaScript
├── tests/
│ ├── __init__.py
│ └── test_basic.py # Test suite
├── requirements.txt # Dependencies
├── example_usage.py # Standalone examples
├── example_prompts.db # Example database
└── README.md # This file
Configuration
Database Settings
You can customize the database path by creating a config.json file in the extension root:
{
"database": {
"default_path": "/path/to/your/prompts.db"
}
}
Relative paths are resolved against the extension directory. Absolute paths are used as-is, which is recommended for Docker deployments where the working directory may not persist:
{
"database": {
"default_path": "/data/custom_nodes/ComfyUI_PromptManager/prompts.db"
}
}
Database Path Compatibility (#211)
PromptManager now honors the database.default_path setting in config.json
when loaded as a ComfyUI custom node. Relative paths resolve against the extension
directory, not ComfyUI's working directory; absolute paths are used as-is. Earlier
versions could ignore this setting and use instead.
Honoring a different configured path can therefore show an empty or different
library. PromptManager does not automatically move or merge database files.
Before upgrading or changing this setting:
- Identify the database your current installation actually uses and confirm its
/prompts.db ; keep track of which existing file you intend to use.
- Preserve a consistent backup of the active database with the dashboard's
-wal file. For a filesystem copy, stop ComfyUI cleanly first and preserve any
remaining -wal file together with the main database.
- Set
database.default_pathto the existing intended database file. An absolute
- Restart ComfyUI, then verify that the expected library appears and the active
Gallery & Monitoring Settings
Configure the automatic image detection and gallery system:
# Gallery monitoring configuration (GalleryConfig class)
MONITORING_ENABLED = True
MONITORING_DIRECTORIES = [] # Auto-detect ComfyUI output if empty
SUPPORTED_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.webp', '.gif']
PROCESSING_DELAY = 2.0 # Delay before processing new images
PROMPT_TIMEOUT = 120 # Seconds to keep prompt context active
CLEANUP_INTERVAL = 300 # Seconds between cleanup of expired prompts
Performance settings
MAX_CONCURRENT_PROCESSING = 3
METADATA_EXTRACTION_TIMEOUT = 10 # Seconds for PNG analysis
IMAGES_PER_PAGE = 20
THUMBNAIL_SIZE = 256
Web Interface Settings
Configure the web interface behavior:
# Web UI settings (PromptManagerConfig class)
RESULT_TIMEOUT = 5 # Seconds to auto-hide results in ComfyUI node
WEBUI_DISPLAY_MODE = 'newtab' # 'popup' or 'newtab' for Web UI button
INFINITE_SCROLL = False # Dashboard list loads the next page on scroll by default
SHOW_TEST_BUTTON = False # Show API test button in node UI
All of these are editable in the dashboard Settings modal and saved to config.json (which is private to the installation and holds the CivitAI key, so it is never committed).
Performance Tuning
- Worker threads (Settings → Performance): threads used by the image rescan, thumbnail generation and duplicate detection. Default is half the detected cores, maximum is the core count. Pillow releases the GIL while decoding, so the scan and thumbnails scale almost linearly; keep a few cores free while ComfyUI is generating.
- The database automatically creates indexes for optimal search performance
- Regular
VACUUMoperations keep the database optimized - Consider backing up the database periodically
Advanced Features
Export Your Prompts
from database.operations import PromptDatabase
db = PromptDatabase()
Export to JSON
db.export_prompts("my_prompts.json", format="json")
Export to CSV
db.export_prompts("my_prompts.csv", format="csv")
Database Statistics
info = db.model.get_database_info()
print(f"Total prompts: {info['total_prompts']}")
print(f"Average rating: {info['average_rating']}")
Backup and Restore
# Create backup
db.model.backup_database("backup_prompts.db")
The online backup includes committed data still in the WAL.
Development
Running Tests
cd ComfyUI_PromptManager
pip install -r requirements-dev.txt
python -m unittest discover -s tests # Python (what CI runs)
node --test tests/js/*.test.js # frontend pure modules
python -m coverage run -m unittest discover -s tests && python -m coverage combine && python -m coverage report
CI runs the suite on Linux, Windows and macOS for Python 3.10 to 3.12 with an 85% coverage gate. Tests that delete a database file first check that nothing in the process still holds it open (tests/open_handles.py), so a connection leak fails on Linux the way it would on Windows.
Code Style
The project follows PEP 8 guidelines with:
- Black formatter (88 character line limit)
- Type hints for all functions
- Comprehensive docstrings
- Proper error handling
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Troubleshooting
Common Issues
Database Permission Errors
- Ensure the ComfyUI process has write permissions to the node directory
- Check that the database file isn't locked by another process
- Verify ComfyUI is properly installed
- Check that all required dependencies are available
- Run
VACUUMon the database occasionally - Consider archiving old prompts if the database becomes very large
Debug Mode
For debugging, you can enable verbose logging in the node:
# Add to prompt_manager.py
import logging
logging.basicConfig(level=logging.DEBUG)
License
MIT License - see LICENSE file for details.
Support
- Issues: Report bugs and request features via GitHub Issues
- Documentation: See the Wiki for detailed guides
- Community: Join the discussion in ComfyUI Discord
Roadmap
Recently Completed
- ✅ Security & Reliability Hardening (3.3.0): validated gallery roots, contained file serving, safe backups and restores, background scans, 85%+ test coverage on all three operating systems
- ✅ Worker Threads: scan, thumbnails and duplicate detection run on a configurable thread pool
- ✅ Tag Autocomplete & Infinite Scrolling: faster browsing in the dashboard and gallery
- ✅ Queue-Time Run Counting (3.2.4): run counts and image linking follow the ComfyUI queue
- ✅ LoRA Manager Integration: Import LoRA metadata, trigger words, and preview images
- ✅ Folder Filter: Browse and filter prompts by output subdirectory
- ✅ Multi-Directory Gallery: Scan multiple output directories simultaneously
- ✅ WD14 Tagger: Fast ONNX-based auto-tagging with Danbooru tags
- ✅ Tailwind v4 Migration: ComfyUI theme token system for consistent styling
- ✅ Tag Management Page: Dedicated page for tag search, rename, merge, and delete
- ✅ Junction Table Tags: Normalized tag storage with proper foreign keys
Planned Features
- ☁️ Cloud Sync: Optional cloud backup and sync
- 🤝 Collaboration: Share prompt collections with other users
- 🧠 AI Suggestions: Recommend similar prompts based on metadata analysis
- 📈 Advanced Analytics: Detailed usage statistics and trends with workflow insights
- 🔄 Workflow Templates: Save and reuse common workflow patterns
- 📊 Visual Analytics: Charts and graphs for prompt effectiveness analysis
Changelog
v3.3.1 (Proxy Routing Fix)
- 🌐 Proxy support: the dashboard, gallery, tag page and metadata viewer now work when ComfyUI is reached through a proxy mount such as SwarmUI's
/ComfyBackendDirect/. Scripts, images, API calls, progress streams and gallery folder filters stay under the mount, and the canvas node's buttons use ComfyUI'sfileURL(). Direct ComfyUI URLs are unchanged. Thanks to @ghosttigerllc-bit (#164) - 📦 Dependencies: the runtime minimums stay at
Pillow>=8.0.0andwatchdog>=2.1.0, so updating Prompt Manager never forces upgrades in the shared ComfyUI environment
v3.3.0 (Hardening, Background Jobs & Worker Threads)
- 🔒 Security: gallery roots restricted to ComfyUI directories and validated wherever they are read; media-only, fail-closed image serving; Windows path escape in static routes closed; quote-safe HTML escaping with inline handlers moved to data attributes; the CivitAI key is never returned and only sent to HTTPS CivitAI hosts; auto-tag paths contained; side-effect routes are POST-only; backups include the WAL and restores are size-capped, integrity-checked and applied through SQLite's online backup API
- 🧵 Worker Threads: a Settings slider (default half the cores) used by the image rescan, thumbnail generation and duplicate detection. Measured: a 1 GB sample scanned in 2.5 s instead of 18 s at 8 threads
- 🔁 Background Jobs: the image rescan and the duplicate scan run on the server, stream progress, survive a closed tab, minimize to a progress pill and re-attach after a reload
- 🎬 Video Prompts: the scan reads the prompt ComfyUI's video savers embed in MP4/MOV/WebM containers (needs
ffprobe) - 🖼️ Thumbnails: written atomically and served under versioned URLs so a regenerated thumbnail never shows a stale cached copy; the per-run cap applies only to thumbnails that still need generating and the gallery says how many remain
- 🏷️ Tag Autocomplete: the dashboard tag box suggests tags, narrowed to those that co-occur with the tags already typed
- ♾️ Infinite Scrolling: optional in the gallery and the dashboard list (saved default plus a session toggle)
- ⚙️ Gallery Settings now apply at load; grid columns, media info and the Rescan button work as labelled
- 🐛 Correctness: run counts increment when ComfyUI dequeues a prompt; negative prompts are never traced; per-thread SQLite connections and idempotent migrations (an old rebuild could delete every image row);
truncate_logsno longer rolls the log over; the ComfyUI canvas loads only the canvas extension; Windows console banners are ASCII-safe; subfolders use/on every platform - 🧪 Tests & CI: 1,460 Python and 142 JavaScript tests (from 510 and 26), coverage 96% with an 85% gate, CI on Linux, Windows and macOS for Python 3.10–3.12, flake8 clean
- ⚠️ API changes: image paths in responses are relative to the ComfyUI tree (use
url);autotag/download,autotag/startand the thumbnail progress stream are POST-only;lora/statusreturnshas_civitai_api_keyinstead of the key;/searchis paginated
v3.2.4 (Recently Used Sorting & Queue-Time Run Counts)
- 🕒 Recently Used Sort: sort the dashboard by last use, most used or rating, server-side across pages
- 🔢 Run Counts:
run_countandlast_used_atare recorded through the ComfyUI queue hook, so cached nodes still count - 🔗 Positive-Prompt Image Linking: generated images link to the positive prompt traced through the queued graph
v3.2.1 (LoRA Manager Integration)
- 🔗 LoRA Manager Integration: Import LoRA metadata, trigger words, and CivitAI example images from ComfyUI-Lora-Manager into your prompt database
- 💉 Auto-Inject Trigger Words: Optionally append LoRA trigger words when
is detected in prompts during encoding - 🔑 CivitAI API Key Support: Authenticate with CivitAI to download NSFW preview images
- 📥 Import Progress Modal: Real-time SSE streaming progress during LoRA import with per-model status
Note: LoRA Manager support is a WIP — this was a highly requested feature. Please open issues for any bugs or feature requests.
v3.2.0 (Folder Filter & QoL Improvements)
- 📁 Folder Filter: New folder dropdown in the search panel to filter prompts by output subdirectory
- 📂 Multi-Directory Gallery Scan: Configure multiple output directories and browse them all in one gallery
- 🖼️ Filmstrip Prompt Display: Show prompt text and copy button in the filmstrip image viewer
- 🖱️ Click-to-Close Viewer: Click outside the image viewer to close it
- 🐛 Bug Fixes: Fixed database path config, UnboundLocalError in text inputs, node caching skip, diagnostics singleton lifecycle
v3.1.0 (WD14 Tagger, Tailwind v4 & Major Refactors)
- 🏷️ WD14 Tagger Support: Added WD14 SwinV2 and WD14 ViT as new auto-tag model options — fast ONNX-based classifiers (~400MB) that output Danbooru tags with confidence scores, no prompt needed
- 🎚️ Threshold Controls: Adjustable general tag (default 0.35) and character tag (default 0.85) confidence thresholds for WD14 models via UI sliders
- 🎨 Tailwind v4 Migration: Complete frontend redesign with ComfyUI theme token system (
--pm-*design tokens) that adapts to ComfyUI's color palette - 🏗️ API Refactor: Split monolithic
api.pyinto domain-specific route modules for better maintainability - 🗃️ Junction Table Tags: Migrated tag storage from JSON column to normalized junction tables with proper foreign keys
- 📄 Tags Page: Dedicated tag management page with search, rename, merge, and delete operations
- 🔍 Load More Button: Progressive prompt loading instead of traditional pagination
- 🔒 Security Hardening: Resolved 15 GitHub code scanning alerts, prevented stack trace exposure in SSE errors
- 🧪 Test Coverage: Added comprehensive unit tests for validators, hashing, metadata, config, and prompt tracker; API integration tests; database tests with CI pipeline
- ⚙️ CI/CD Improvements: Added code quality scanning, security scanning, Dependabot, and pre-commit hooks with Black formatting
- 🐛 Bug Fixes: Fixed custom image scan directory config (#108), gallery crash on thumbnail linking, broken imports after API refactor, widget value sync issues, and prepend/append metadata tag filtering in auto-tagger
v3.0.26 (Top Bar Button)
- 🔘 Top Bar PM Button: Added a "PM" button to the ComfyUI top bar for quick access to the admin dashboard
- 🚀 No Node Required: Open PromptManager without having to add the node to your workflow first
- 🎨 Teal Button Design: Distinctive teal-colored button positioned before the settings gear
- 🔄 Frontend Compatibility: Works with both new ComfyUI frontend (v1.3.1+) and legacy versions
v3.0.25 (Film Strip & QoL Improvements)
- 🎞️ Film Strip Preview: Backported from V2 - thumbnail strip under each prompt showing linked images
- 🖼️ Quick Image Viewer: Click any filmstrip thumbnail to open full-size image viewer
- 📸 Smart Thumbnails: Automatically uses generated thumbnails for faster loading, falls back to full images
- ⬆️ Auto-Scroll on Pagination: Page navigation now smoothly scrolls to top after loading
v3.0.24 (Manual Prompt Creation)
- ➕ Add Prompt Button: New "Add Prompt" button in the admin dashboard Bulk Actions bar
- 📝 Direct Prompt Creation: Create prompts directly from the UI without generating images
- 🛡️ Protection from Pruning: New prompts are automatically protected from orphan cleanup by default
- 🏷️ Full Metadata Support: Set category, tags, rating, and notes when creating prompts
- 🔒 Orphan Protection Toggle: Option to protect or unprotect prompts from maintenance cleanup
... (README truncated for length)