ComfyUI Node

My ComfyUI Node

My ComfyUI Node Is a Template, Not a Tool — Here's What It Actually Is

By develephant·Created 6 months ago·Updated 6 months ago· 0
My ComfyUI Node
    • output
    prefix
    slider_float20.0
    slider_int5
    togglefalse

    Let's get the awkward part out of the way: if you found this page hoping MyComfyNode does something useful in a workflow, it doesn't. It returns a string that says "run output True" (or False, if you flip the toggle). That's it. It's not a bug - this node is the hello-world that ships inside develephant/comfyui-node-template, a starter template for people who want to write their own custom nodes. You install it to copy it, not to run it.

    That's genuinely useful, though, if you're at that stage. Writing your first ComfyUI custom node is fiddly - there's a pile of boilerplate (INPUT_TYPES, RETURN_TYPES, FUNCTION, CATEGORY, the two mapping dicts in __init__.py) that's easy to get wrong. This template hands you all of it in one ~60-line file and says "replace the bits that are yours." Given how much of the ecosystem's frustration (missing nodes, dependency hell, the ComfyUI-Manager dance) stems from the sheer volume of third-party packs, understanding how a node is put together is the difference between blindly installing and actually being able to fix what breaks.

    How it works

    The anatomy is textbook. nodes.py defines the MyComfyNode class with an INPUT_TYPES classmethod that declares four inputs, a RETURN_TYPES/RETURN_NAMES pair, FUNCTION = "execute", and a CATEGORY. The mappings in __init__.py tell ComfyUI the class name and the display name you see in the node menu. It's split into the pattern the template wants to teach you: the node class stays thin and delegates the actual work to MyExecuteClass in execute.py, so your logic lives in a plain Python class you can unit-test without loading ComfyUI. Two details are worth stealing for your own nodes: OUTPUT_NODE = True marks the node as a terminal output, and the IS_CHANGED method returns float("nan"), which forces ComfyUI to skip caching and re-run every execution.

    One quirk if you're studying it: of the four declared inputs, execute() only actually uses toggle - prefix, slider_float, and slider_int are defined but never touched. It's a template, so the scaffolding is complete but the logic is placeholder. Good to know before you wonder why your prefix isn't showing up.

    The inputs that matter

    There are four inputs, all required, and none do anything except demonstrate input types:

    • prefix (STRING) - a text field, tooltip "a prefix."
    • slider_float (FLOAT, default 20, 1–99, step 0.5) - a float slider.
    • slider_int (INT, default 5, 1–20) - an integer slider.
    • toggle (BOOLEAN, default off) - the only one that reaches the execute function; it flips the output between True and False.

    The single output, output (STRING), is a dead-end string node - wire it to anything that accepts text, or nothing at all.

    Install it

    Honestly, the "install" is a fork, not an install. Clone it, rename the folder, and start editing:

    cd ComfyUI/custom_nodes
    git clone https://github.com/develephant/comfyui-node-template
    # or use the GitHub "Use this template" button to get a fresh repo of your own
    

    Then restart ComfyUI and the node appears under category in the menu. The pack needs no requirements.txt, no models, no GPU - pure Python stdlib, so it's the safest possible first pack to dissect. If you'd rather grab it through ComfyUI Manager, search its title "comfyui-node-template" there; either path lands you the same four files.

    Gotchas

    Since the template forces a cache refresh on every run, it'll re-execute constantly - fine for a demo, but copy the pattern into a production node only if you actually want no caching. And remember: this pack's README frames itself as your starting point, so the category path (category/MyComfyNode) is a placeholder you'll want to rename. If you load someone's workflow and it complains about a missing MyComfyNode, what you're really missing is their custom node - this template is only the skeleton.

    Categorycategory/MyComfyNode

    Inputs (4)

    NameTypeDefaultDescription
    prefixSTRINGa prefix
    slider_floatFLOAT20.01–99
    slider_intINT51–20
    toggleBOOLEANfalsetoggle me

    Outputs (1)

    NameTypeDescription
    outputSTRING