A simple ComfyUI node example project to help beginners learn how to develop ComfyUI nodes.
The project contains a simple example node ImageInfoNode
that:
- Accepts an input image
- Outputs basic information about the image (size, format, etc.)
- Locate your ComfyUI custom nodes directory (usually at
ComfyUI/custom_nodes/
) - Clone this project in that directory:
cd custom_nodes
git clone https://github.com/yourusername/ComfyUI-NodeSample
- Open ComfyUI
- Open ComfyUI Manager
- Go to "Install Custom Nodes" tab
- Search for "ComfyUI Node Sample"
- Click Install
This project demonstrates how to properly manage dependencies in your ComfyUI custom nodes.
- Create a
requirements.txt
file in your project root:
Pillow>=9.0.0
numpy>=1.21.0
ComfyUI Manager will automatically install these dependencies when users install your node.
For more complex dependency management:
- Create an
install.py
script in your project root:
import os
import subprocess
import sys
def ensure_dependencies():
# Get the directory where this script is located
script_dir = os.path.dirname(os.path.abspath(__file__))
# Get Python executable path from ComfyUI's environment
python = sys.executable
print("Installing dependencies...")
# Install dependencies using pip in the correct Python environment
subprocess.check_call([python, '-m', 'pip', 'install', '-r',
os.path.join(script_dir, 'requirements.txt')])
if __name__ == "__main__":
ensure_dependencies()
-
Version Specification:
- Always specify minimum version requirements
- Use
>=
for minimum version requirements - Example:
Pillow>=9.0.0
-
Dependency Isolation:
- Use ComfyUI's Python environment
- Don't modify system-wide Python packages
- Test your dependencies with different ComfyUI versions
-
Conflict Prevention:
- Check for existing dependencies in ComfyUI
- Use compatible versions with ComfyUI's requirements
- Document any potential conflicts
-
Error Handling:
- Add proper error messages for missing dependencies
- Provide troubleshooting steps in documentation
- Example code for checking dependencies:
try:
import PIL
import numpy as np
except ImportError:
print("Required dependencies are not installed. Please install them using:")
print("pip install -r requirements.txt")
- Start ComfyUI
- Find "Image Info" node in the node list
- Connect an image node to the Image Info node's input
- Run the workflow to see the image information
This project demonstrates the basic structure of creating a ComfyUI node, including:
- Node class definition
- Input/output interface definition
- Node registration process
You can use this template to develop your own nodes.
To make your node available in ComfyUI Manager:
- Create a GitHub repository for your node
- Add a
ComfyUI
tag to your repository - Create a custom_nodes.json file in your repository root:
{
"your_node_name": {
"title": "Your Node Title",
"description": "A brief description of your node",
"tags": ["image", "utility"],
"repository": "github_username/repository_name",
"install_type": "git_clone"
}
}
- Submit your repository to the ComfyUI Manager Custom Nodes List via pull request