Use when the user wants to create a ComfyUI custom node, convert Python code to a node, make a node from a script, or needs help with ComfyUI node development, INPUT_TYPES, RETURN_TYPES, or node class structure.
Add this skill
npx mdskills install ConstantineB6/comfy-nodesPractical ComfyUI node development guide with clear templates, type mappings, and batch handling examples
1---2name: comfy-nodes3description: Use when the user wants to create a ComfyUI custom node, convert Python code to a node, make a node from a script, or needs help with ComfyUI node development, INPUT_TYPES, RETURN_TYPES, or node class structure.4version: 1.0.05---67# ComfyUI Custom Node Development89This skill helps you create custom ComfyUI nodes from Python code.1011## Quick Template1213```python14class MyNode:15 @classmethod16 def INPUT_TYPES(cls):17 return {18 "required": {19 "image": ("IMAGE",),20 "value": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0}),21 },22 "optional": {23 "mask": ("MASK",),24 }25 }2627 RETURN_TYPES = ("IMAGE",)28 RETURN_NAMES = ("output",)29 FUNCTION = "execute"30 CATEGORY = "Custom/MyNodes"3132 def execute(self, image, value, mask=None):33 result = image * value34 return (result,)3536NODE_CLASS_MAPPINGS = {"MyNode": MyNode}37NODE_DISPLAY_NAME_MAPPINGS = {"MyNode": "My Node"}38```3940## Converting Python to Node4142When you have Python code to wrap:4344### Step 1: Identify inputs and outputs45```python46# Original function47def apply_blur(image, radius=5):48 from PIL import ImageFilter49 return image.filter(ImageFilter.GaussianBlur(radius))50```5152### Step 2: Map types5354| Python Type | ComfyUI Type | Conversion |55|-------------|--------------|------------|56| PIL Image | IMAGE | `torch.from_numpy(np.array(pil) / 255.0)` |57| numpy array | IMAGE | `torch.from_numpy(arr.astype(np.float32))` |58| cv2 BGR | IMAGE | `torch.from_numpy(cv2.cvtColor(img, cv2.COLOR_BGR2RGB) / 255.0)` |59| float 0-255 | IMAGE | Divide by 255.0 |60| Single image | Batch | `tensor.unsqueeze(0)` |6162### Step 3: Handle batch dimension6364ComfyUI images are `[B,H,W,C]` - always process all batch items:6566```python67def execute(self, image, radius):68 batch_results = []69 for i in range(image.shape[0]):70 # Convert to PIL71 img_np = (image[i].cpu().numpy() * 255).astype(np.uint8)72 pil_img = Image.fromarray(img_np)7374 # Your processing75 result = pil_img.filter(ImageFilter.GaussianBlur(radius))7677 # Convert back78 result_np = np.array(result).astype(np.float32) / 255.079 batch_results.append(torch.from_numpy(result_np))8081 return (torch.stack(batch_results),)82```8384## Common Input Types8586| Type | Shape/Format | Widget Options |87|------|--------------|----------------|88| IMAGE | [B,H,W,C] float 0-1 | - |89| MASK | [H,W] or [B,H,W] float 0-1 | - |90| LATENT | {"samples": [B,C,H,W]} | - |91| MODEL | ModelPatcher | - |92| CLIP | CLIP encoder | - |93| VAE | VAE model | - |94| CONDITIONING | [(cond, pooled), ...] | - |95| INT | integer | default, min, max, step |96| FLOAT | float | default, min, max, step, display |97| STRING | str | default, multiline |98| BOOLEAN | bool | default |99| COMBO | str | List of options as type |100101## Checklist102103- [ ] `INPUT_TYPES` is a `@classmethod`104- [ ] Return value is a tuple: `return (result,)`105- [ ] Handle batch dimension `[B,H,W,C]`106- [ ] Add to `NODE_CLASS_MAPPINGS`107- [ ] Category uses `/` for submenus108109## References110111- [NODE_TEMPLATE.md](references/NODE_TEMPLATE.md) - Full template with V3 schema112- [OFFICIAL_DOCS.md](references/OFFICIAL_DOCS.md) - Official ComfyUI documentation113- [PURZ_EXAMPLES.md](references/PURZ_EXAMPLES.md) - Example nodes and workflows114115## Finding Similar Nodes116117Use the MCP tools to find existing nodes for reference:118119```120comfy_search("blur") → Find blur implementations121comfy_spec("GaussianBlur") → See how inputs are defined122```123
Full transparency — inspect the skill content before installing.