Module f-comfyui · Image · 8 min

ComfyUI workflow
as code.

Treating .json workflows as version-controlled artifacts.

Reading time8 min Audio- Prerequisites14 SourceTrack A · Gemini
§ 1

What this lesson covers.

This module is one of 42 in the curriculum. Below is the canonical interactive lesson — tabs, cards, and diagrams from the source repo, rendered inside the course shell. There is no audio narration for this module - it ships as text + interactive lesson only.

If you prefer to read first and play with the demos after, the interactive lesson sits below this section. If you'd rather hear it narrated while you scroll, hit play on the sticky audio bar at the top — or just let it autoplay.

§ 2

The lesson itself.

Interactive lesson · ported from Gemini track Click tabs to navigate · hover cards for details
Image · Tooling

ComfyUI — Workflow as Code

Node graphs as version-controllable artifacts · the dataflow paradigm for image gen

WHY GRAPHS

The image-gen pipeline is a dataflow, not a sequence of calls

A full image generation involves: load checkpoint, encode positive prompt, encode negative prompt, generate noise latent, KSampler with model + conditioning + latent, VAE decode, save image. Each step has dozens of optional parameters. Linear scripts (the old way) became unmaintainable; ComfyUI's node graph makes the pipeline structure visible and modifiable.
GRAPH AS JSON

A ComfyUI workflow is a .json file you can version-control

Every node graph serializes to JSON. workflow.json sits next to the output image. Treat it like code: commit it, diff it, share it. A typical Stable Diffusion workflow is 8-15 nodes; an advanced pipeline with ControlNet + IP-Adapter + LoRAs + upscaler easily hits 40-60 nodes. The JSON is the reproducible artifact.
CUSTOM NODES

The ecosystem fragments, then re-converges

Anyone can write a custom node in Python. The ComfyUI manager has 1000+ third-party node packs. The downside: custom nodes age fast as the API evolves. Best practice: pin your dependency set, snapshot a Docker image, or accept that production workflows need maintenance. Treat custom nodes like NPM packages — version-pin them or lock them with a manifest.
PRODUCTION DEPLOYMENT

From the desktop UI to a serving endpoint

ComfyUI has a built-in REST API. POST your workflow JSON + any input images, get back a queue ID, poll for completion. The studio pattern: develop interactively in the web UI, save the workflow.json, deploy via the API. ComfyUI-API and ComfyUI-Worker projects wrap this into proper task queues. The Macalinao Studio Generation Stack centers on this pattern for image / video work.
§ DEMO

Try it: comfyui workflow graph.

Drag-and-drop node graph. Connect outputs to inputs, see a real Stable Diffusion workflow build itself.

ComfyUI Workflow Graph · interactiveOpen standalone
§ PAPERS

Further reading.

The canonical references for this module. External links open in a new tab.

§ NEXT

What to read next.

Use the pager below to move sequentially through the curriculum, or jump to any module from the course index. Each track has a "Prereq: ↑ foundation" callout so you can backfill anything that wasn't clear.