Skip to main content
Follow these best practices to create reliable, performant, and user-friendly custom nodes for ComfyUI.

Code Organization

File Structure

Organize your extension with a clear directory structure:

Module Naming

Use descriptive, unique names to avoid conflicts:

Performance Optimization

Use Lazy Inputs

Implement lazy evaluation for expensive operations:

Implement Fingerprinting

Avoid re-execution when inputs haven’t meaningfully changed:

Memory Management

Be mindful of GPU memory:

User Experience

Provide Helpful Tooltips

Add clear, descriptive tooltips:

Use Appropriate Input Types

Choose the right input type and display mode:

Sensible Defaults

Provide good default values:

Error Handling

Validate Inputs

Check inputs and provide clear error messages:

Handle Edge Cases

Consider edge cases in your implementation:

Documentation

Docstrings

Document your nodes with clear docstrings:

Example Workflows

Provide example workflows in example_workflows/:

README

Include comprehensive README:

Nodes

Image Blur

Blurs an image using Gaussian blur. Inputs:
  • image: Input image
  • radius: Blur radius (0-100)
Outputs:
  • image: Blurred image

Versioning and Compatibility

Version Your Extension

Use semantic versioning:

Maintain Backwards Compatibility

When updating nodes, preserve compatibility:

Common Patterns

Progress Reporting

Report progress for long operations:

Batch Processing

Handle batch inputs efficiently:
Always test your nodes with different batch sizes to ensure correct behavior.

Security Considerations

Validate File Paths

Never trust user-provided paths:

Sanitize Inputs

Validate and sanitize all user inputs:
Follow these best practices to create nodes that are fast, reliable, and user-friendly!