2025-12-07 12:57:45 -06:00
2025-12-07 12:57:45 -06:00
2025-12-07 12:57:45 -06:00
2025-12-07 12:57:45 -06:00
2025-12-07 12:57:45 -06:00
2025-12-07 12:57:45 -06:00
2025-12-07 12:57:45 -06:00
2025-12-07 13:00:46 -06:00
2025-12-07 12:57:45 -06:00
2025-12-07 12:57:45 -06:00
2025-12-07 12:57:45 -06:00

ComfyUI Prompt Store

A custom node system for ComfyUI that enables efficient prompt management, selection, and interpolation. This extension provides a YAML-based datastore for organizing prompts into categories and includes powerful text interpolation capabilities for dynamic prompt composition.

Features

  • Prompt Categories: Organize prompts into logical categories
  • Prompt Selection: Easy-to-use node interface for selecting and using stored prompts
  • Text Interpolation: Powerful variable substitution and text combination patterns
  • YAML Datastore: Persistent, human-editable prompt storage
  • Dynamic Composition: Combine multiple prompts with variable substitution
  • ComfyUI Integration: Seamless integration with ComfyUI workflows

Installation

  1. Clone or download this repository into your ComfyUI custom_nodes folder:
cd custom_nodes
git clone https://github.com/yourusername/comfyui-promptstore.git
cd comfyui-promptstore
  1. Install dependencies:
pip install -r requirements.txt

Nodes

Prompt Template

The Prompt Template is a simple node - it just allows you to enter some text to be used as a template for your prompts.

This node is here just so you don't have to install other custom nodes just to enter some text.

Prompt Selector

The Prompt Selector node allows you to select and modify prompts from your stored categories with optional variable interpolation.

Inputs

  • category (required): Select from your defined prompt categories
  • prompt_title (required): Select a specific prompt from the chosen category
  • prompt (required): The actual prompt text (can include interpolation patterns)
  • initial_prompt (optional): An initial prompt to pass through interpolation

Output

  • Prompt: The processed prompt string (after interpolation if applicable)

Example Usage

Simple Prompt Selection

Text Interpolation

The text interpolation system allows you to create dynamic prompts by combining strings and substituting variables. It supports three main patterns:

Pattern 1: Placeholder Expansion ({})

The {} placeholder in the text will be replaced with the initial_prompt after processing any variable definitions from it.

For example, a simple substitution can look like this:

Appending To The Prompt

Since you can chain the Prompt Selectors you can also get something like this:

Inline Substitution

Pattern 2: Variable Substitution ${varname:value}

That's already good, but a bit limited. Sometimes you may want to have more complex prompt creation, where something stays fixed, and other things may change. So you may have a prompt that says:

Henry is standing in the foreground with a wide stance.

And you may have different subjects you want to describe as Henry. What you can do is define the subject name as a variable and then use it in a saved prompt. So - the prompt above - could be written as:

${subject:Henry} is standing in the foreground with a wide stance.

And you can have a saved prompt for your subjects that looks like:

${subject} is a middle-aged Greek fisherman with short gray hair and a weathered skin. Wrinkles on his face and
deep hazel eyes.

{}

The output prompt would be:

Henry is a middle-aged Greek fisherman with short gray hair and a weathered skin. Wrinkles on his face and
deep hazel eyes.

Henry is standing in the foreground with a wide stance.

A picture is worth a thousand words:

Simple Variable Substitution

Pattern 3: Inline Structural Substitution (@{var})

The @{var} pattern performs structural substitution. It will replace the placeholder in the text with the prompt defined with the same variable name. So, if your prompt is:

The subject is standing in front of @{background}.

The subject is happy, wondering how it all works.

And you selected a prompt for a background like this:

@{background}
a large decorative window

The output will be:

The subject is standing in front of a large decorative window.

The subject is happy, wondering how it all works.

Take a look at this example showing how these can be combined:

Inline and Veriable Substitution Example

A bit about the prompt Storage

Prompts are stored in a YAML file - in user/comfyui-promptstore/promptstore.yaml with the following structure:

categories:
  - portrait
  - landscape
  - character

portrait:
  - A professional headshot portrait
  - A romantic portrait with soft lighting
  - A dramatic character portrait

landscape:
  - A scenic mountain landscape at sunset
  - An expansive valley under clear skies

character:
  - A fantasy warrior with detailed armor ${armor:steel}
  - A mysterious figure shrouded in shadow @{description}

YAML Datastore API

The underlying YAML datastore provides:

Category Methods

  • get_categories() - Get list of all categories
  • create_category(category) - Create a new category
  • remove_category(category) - Remove a category and all prompts
  • category_exists(category) - Check if category exists

Prompt Methods

  • get_prompts(category) - Get all prompts in a category
  • add_prompt(category, prompt) - Add a prompt to a category
  • remove_prompt(category, prompt) - Remove a prompt from a category
  • prompt_exists(category, prompt) - Check if a prompt exists
  • get_all_prompt_titles() - Get all prompt titles across categories

Utility Methods

  • get_all_data() - Get complete datastore contents

Usage Examples

Basic Workflow: Simple Prompt Selection

  1. Add a Prompt Selector node to your ComfyUI workflow
  2. Choose a category from the dropdown
  3. Select a prompt from that category
  4. The selected prompt text flows to your image generation nodes

Advanced Workflow: Variable Substitution

Create prompts with variables to avoid duplication:

style_prompts:
  - A ${style:photorealistic} portrait of a person
  - A ${style:painting} of a landscape
  - A ${style:digital art} character design

Then in your node, select the prompt and it will automatically substitute the style variable.

Advanced Workflow: Structural Substitution

Build complex prompts by combining base templates with specific details:

templates:
  - A ${mood:peaceful} scene @{details}
  
details:
  - with a sunset in the background
  - with mountains visible in the distance
  - with people enjoying the view

Tips & Best Practices

  1. Organize by Purpose: Use categories that reflect your workflow (e.g., "character_descriptions", "environment_details", "style_modifiers")

  2. Use Variables for Common Values: Create variations with ${var:default} patterns to avoid repeating similar prompts

  3. Chain Prompts: Use the @{var} pattern to build complex prompts from multiple stored segments

  4. Keep Prompts Reusable: Write prompts that work well with interpolation rather than hard-coding specific details

  5. Document Complex Patterns: Add comments in your YAML file (using #) to explain what variables are used in each prompt

Requirements

  • Python 3.6+
  • PyYAML
  • ComfyUI

Troubleshooting

  • Categories not appearing: Ensure your YAML file is properly formatted and categories are defined
  • Interpolation not working: Check that variable names match exactly (they're case-sensitive)
  • Prompt not updating: Restart ComfyUI after modifying your YAML prompt file

License

See LICENSE file for details.

S
Description
No description provided
Readme MIT
640 KiB
Languages
Python 54.9%
JavaScript 45.1%