- Setup & Prerequisites
- Project Structure
- Node Development
- Testing & Debugging
- Publishing & Distribution
- Best Practices
- Node Registry Integration
- Python 3.10+
- Git
- ComfyUI installed locally
- Basic understanding of Python and Node.js
# Clone ComfyUI if you haven't already
git clone https://github.com/comfyanonymous/ComfyUI
cd ComfyUI
# Create custom_nodes directory if it doesn't exist
mkdir -p custom_nodes
cd custom_nodes
# Create your node project
mkdir my-custom-nodes
cd my-custom-nodes
Standard directory structure for a ComfyUI custom node project:
my-custom-nodes/
├── __init__.py # Main entry point
├── nodes/ # Node implementations
│ ├── __init__.py
│ ├── node1.py
│ └── node2.py
├── js/ # Frontend components
│ └── extensions.js # UI customizations
├── requirements.txt # Python dependencies
└── README.md # Documentation
# nodes/example_node.py
class ExampleNode:
"""
Node documentation goes here.
"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"input1": ("STRING", {"default": "default value"}),
"input2": ("INT", {"default": 0, "min": 0, "max": 100}),
},
"optional": {
"optional_input": ("FLOAT", {"default": 1.0}),
}
}
RETURN_TYPES = ("STRING", "INT")
RETURN_NAMES = ("output1", "output2")
FUNCTION = "process"
CATEGORY = "examples"
def process(self, input1, input2, optional_input=1.0):
# Process inputs and return outputs
return (f"Processed {input1}", input2 + 1)
# Node registration
NODE_CLASS_MAPPINGS = {
"ExampleNode": ExampleNode
}
NODE_DISPLAY_NAME_MAPPINGS = {
"ExampleNode": "Example Node"
}
STRING
: Text inputINT
: Integer numberFLOAT
: Decimal numberBOOLEAN
: True/False toggleIMAGE
: Image dataLATENT
: Latent space representationMODEL
: ML modelCONDITIONING
: Prompt conditioningCOMBO
: Dropdown selection
class CustomWidget:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"custom_input": (
"CUSTOM", {
"widget": {
"type": "custom_widget",
"options": {"param1": "value1"}
}
}
),
}
}
- Place your node project in ComfyUI's custom_nodes directory
- Restart ComfyUI to load new nodes
- Check the console for loading errors
- Test node in the UI workflow
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
class DebugNode:
def process(self, *args, **kwargs):
logger.debug(f"Processing with args: {args}, kwargs: {kwargs}")
# Process logic here
- Create comprehensive README.md
- Document dependencies in requirements.txt
- Add installation instructions
- Include example workflows
- Add screenshots/demonstrations
-
GitHub Repository
- Clear documentation
- Release tags
- License specification
-
ComfyUI Manager Integration
- Add to custom-node-list.json
- Follow naming conventions
- Include preview images
-
Node Registry (New Standard)
- Register with comfy.org registry
- Implement standardized metadata
- Follow versioning guidelines
- Use type hints
- Document functions and classes
- Follow PEP 8 style guide
- Handle errors gracefully
- Cache expensive operations
class OptimizedNode:
def __init__(self):
self.cache = {}
def process(self, input_data):
cache_key = hash(input_data)
if cache_key in self.cache:
return self.cache[cache_key]
result = self.expensive_operation(input_data)
self.cache[cache_key] = result
return result
- Clear node names and categories
- Informative tooltips
- Sensible default values
- Proper error messages
- Responsive UI updates
The official ComfyUI Node Registry (comfy.org) defines standards for node quality and distribution:
- Metadata Requirements
{
"name": "my-custom-nodes",
"version": "1.0.0",
"author": "Your Name",
"description": "Brief description",
"repository": "https://github.com/username/my-custom-nodes",
"license": "MIT",
"tags": ["category1", "category2"],
"min_comfy_version": "1.0.0",
"max_comfy_version": "2.0.0",
"dependencies": {
"python": ["numpy>=1.20.0"],
"comfy_nodes": ["another-custom-node>=1.0.0"]
}
}
- Quality Guidelines
- Comprehensive documentation
- Working example workflows
- Test coverage
- Performance benchmarks
- Security considerations
- Publishing Process
# Install registry CLI tool
pip install comfy-registry-cli
# Initialize registry config
comfy-registry init
# Validate package
comfy-registry validate
# Publish to registry
comfy-registry publish
-
Version Management
- Semantic versioning
- Changelog maintenance
- Dependency specifications
-
Documentation
- API documentation
- Usage examples
- Installation guide
- Troubleshooting section
-
Testing
- Unit tests
- Integration tests
- Example workflows
- Performance benchmarks
-
Maintenance
- Issue tracking
- Regular updates
- Security patches
- Compatibility checks