A ComfyUI custom node is a Python class with INPUT_TYPES, RETURN_TYPES, FUNCTION, and CATEGORY
Defining a ComfyUI node requires four class-level declarations: INPUT_TYPES() returns a dict of required/optional slot names mapped to (type_string, options) tuples; RETURN_TYPES is a tuple of output type strings; FUNCTION names the method to call; CATEGORY sets the Add Node menu path. The node is registered by adding it to NODE_CLASS_MAPPINGS. Type strings are either built-in ComfyUI types (MODEL, CONDITIONING, LATENT, IMAGE, INT, FLOAT, STRING) or custom strings registered by the node. Adding new optional inputs with defaults preserves backward compatibility; changing existing output types breaks existing workflows.
Examples
class CLIPTextEncode: INPUT_TYPES returns {‘required’: {‘text’: (IO.STRING, {…}), ‘clip’: (IO.CLIP, {…})}}; RETURN_TYPES = (IO.CONDITIONING,); FUNCTION = ‘encode’; CATEGORY = ‘model/conditioning’.
Assessment
Write the skeleton of a custom node that takes an IMAGE and a FLOAT (strength) and returns an IMAGE. Register it as ‘MyFilter’ in category ‘image/filter’.