Utilities for working with ComfyUI node graphs from Python. The project provides typed wrappers around ComfyUI nodes, lightweight graph primitives, and helpers for exporting a workflow back to the JSON format that the ComfyUI API expects.
- Typed Node and Edge models (Pydantic) for tracking dependencies and serialising graphs.
- A generated nodes.py module that mirrors the ComfyUI node catalogue with Python callables.
- Tooling (nodes_to_py.py) to regenerate those bindings directly from a running ComfyUI server.
- Example workflow builder scaffolding that shows how to stitch nodes into higher-level pipelines.
- Python 3.12+
- requests and pydantic (installed automatically when the package is installed)
- Access to a running ComfyUI server when regenerating node bindings
Before using the factory functions, generate nodes.py from your running ComfyUI:
If you omit the URL, it defaults to http://127.0.0.1:8188/. This writes nodes.py based on the server's /object_info. Re-run whenever your ComfyUI nodes change.
You can also generate from a local JSON schema (previously fetched from /object_info):
Create nodes the same way you would wire a ComfyUI graph. Each factory function from nodes.py returns a typed Edge that keeps track of its originating node. When you are ready to export the workflow, grab the source_node of your terminal edge and call build_json_workflow().
- The generator downloads the node schema, sanitises type names, and rewrites nodes.py with updated classes and helper functions.
- The just recipe just run wraps the generation command if you prefer using just.
Thanks to ComfyScript for inspiration and prior art.
.png)


