A simple ComfyUI node development starter template.
Start by defining a node class.
class MyComfyNode: __init__(self): pass@classmethod def INPUT_TYPES(cls): return {"required": { # required entry components go here, }}@classmethod def INPUT_TYPES(cls): return { "required": { # required entry components go here, }, "optional": { # optional entries go here, } }@classmethod def INPUT_TYPES(cls): return {}Creates a string type entry.
"strval": ("STRING", {"default": "a string", "tooltip": "a string entry"})Creates a float slider entry.
"floatval": ("FLOAT", {"default": 20.0, "min" 0.5, "max": 150.0, "step": 0.5, "tooltip": "a float"})Create a integer slider entry.
"intval": ("INT", {"default": 2, "min": 1, "max": 10, "tootip": "an integer"})Create a boolean switch entry.
"boolval": ("BOOLEAN", {"default": False, "tooltip": "a boolean toggle"})Clip Input
"clip": ("CLIP", {"clip_name": "clip_name", "type":"stable_diffusion"})Model Input
VAE Input
Conditioning Input
Image Input
Mask Input
Latent Input
Clip Vision Input
Clip Vision Output
"dropdown": (["opt_1", "opt_2", "opt_3"], "default": "opt_2")@classmethod def INPUT_TYPES(cls): res = s.do_something(cls) @classmethod def do_something(cls): #do work return resUses the same constants as inputs.
RETURN_TYPES = ("STRING", "STRING", "FLOAT",) #output type RETURN_NAMES = ("model", "vae", "amount",) # display nameFUNCTION = "execute" def execute(self): pass #do workCATEGORY = "<category>/MyComfyNode" DESCRIPTION = "My handy ComfyUI node"NODE_CLASS_MAPPINGS = { "MyComfyNode": MyComfyNode, } NODE_DISPLAY_NAME_MAPPINGS = { "MyComfyNode": "My ComfyUI Node" }The custom node directory goes in comfyui/custom_nodes/<my-comfy-node>