Nodes/ComfyUI-WorkflowGenerator/3. Build and Save Workflow
ComfyUI Node

3. Build and Save Workflow

The Last Stop Between a Diagram and a Workflow You Can Actually Load

By DanielPFlorian·Created 9 months ago·Updated 9 months ago· 41
3. Build and Save Workflow
    • workflow_json
    • file_path
    workflow_edges
    catalog_directorycatalog
    save_workflowtrue
    filename_prefixgenerated_workflow

    The final stage of this pack's chain, and the one with the least glamorous job: taking a validated node diagram and turning it into workflow JSON that ComfyUI will actually load and run. It's the "3. Build and Save Workflow" step in the numbered trio, and if you've been following along with the other nodes it's the payoff - the raw diagram from Step 1 is just a list of named connections, not something the canvas can execute. This node is what makes the difference.

    How it works

    WorkflowBuilder takes the edge list (source node, source output, target node, target input) and reconstructs a real ComfyUI graph from it. It looks up each referenced node in the catalog of installed nodes to fetch its actual input and output signatures, assigns IDs, and matches every edge to a real socket pair. Two things make it smarter than a dumb converter:

    • Primitive values get inlined. Types like STRING, FLOAT, INT and BOOLEAN are treated as widget values rather than graph nodes, which is why the allow_primitive_nodes toggle upstream matters - with it off, the builder writes values directly into node widgets and the result is a clean, readable workflow instead of a swamp of tiny boxes.
    • Edges that can't be connected are skipped gracefully rather than killing the whole build. The output is still valid JSON; it just has fewer links than the diagram promised, which is your cue to fix something in Step 1 or 2.

    There's also an auto-layout pass so the resulting nodes land on the canvas in a sensible arrangement instead of a pile. The README calls the output "workflow JSON" and by default it saves to a file with an incrementing counter - generated_workflow_001.json, _002, and so on - in your ComfyUI output folder.

    Inputs and outputs

    Only four inputs, and three of them are near-defaults:

    • workflow_edges - the diagram from WorkflowGenerator (Step 1) or, better, the refined one from NodeValidator (Step 2). This is a connection-only input, so wire it up rather than typing.
    • catalog_directory - where the node catalog lives; defaults to catalog inside the pack folder. You shouldn't need to change it, but it must exist - see the troubleshooting below.
    • save_workflow - on by default. Flip off if you only want the JSON string and no file.
    • filename_prefix - default generated_workflow. You can give it a subdirectory (my_workflows/experiment) and the builder creates it inside the output folder.

    Outputs are workflow_json (the complete, executable workflow - stringify and paste it somewhere, or feed it to a Save Text node) and file_path (where the file landed).

    Install and gotchas

    Install is the pack's standard: clone into custom_nodes, pip install -r requirements.txt, drop the models into ComfyUI/models/LLM/, and restart. The builder itself doesn't need the LLM models - those are Step 1 and 2's problem - but it absolutely needs the catalog files, which come from running the UpdateNodeCatalog node first. If you skip that, you'll get errors about node types not found or unknown nodes.

    The classic failure chain: you generated a diagram, the builder ran, and the saved workflow opens in ComfyUI with a wall of missing or mismatched nodes. Nine times out of ten that's a stale catalog - you installed a new custom node pack and never re-ran UpdateNodeCatalog, so the builder was wiring against an old snapshot of what exists. Re-run the catalog, regenerate, and it goes away. The other cause is skipping the validator entirely: a diagram full of hallucinated node names (the Step 1 model is trained mostly on 2024-era SDXL/SD 1.5 workflows) produces a JSON that loads but does nothing useful. If you skip NodeValidator, at least eyeball the diagram before you build it.

    CategoryWorkflowGenerator

    Inputs (4)

    NameTypeDefaultDescription
    workflow_edgesSTRINGInput diagram from Step 1 or Step 2.
    catalog_directorySTRINGcatalogDirectory containing node catalog files.
    save_workflowBOOLEANtrueSave workflow to file.
    filename_prefixSTRINGgenerated_workflowFilename prefix or path for saved workflow.

    Outputs (2)

    NameTypeDescription
    workflow_jsonSTRINGComplete ComfyUI workflow JSON.
    file_pathSTRINGPath to saved file.