ComfyUI Workflow Templates
The `comfyui-workflow-templates` library provides a convenient Python package to access a collection of pre-defined ComfyUI workflow JSONs. It allows developers to easily retrieve and use these templates programmatically, streamlining the creation and sharing of ComfyUI workflows. The current version is 0.9.45, with updates typically released as new templates are added or existing ones are refined.
Warnings
- gotcha Template names are dynamic strings and can change or be removed between `comfyui-workflow-templates` versions. Relying on hardcoded template names without verification can lead to `KeyError`.
- gotcha The `workflow_json` returned by `get_workflow_template()` is a raw Python dictionary representation of the ComfyUI workflow JSON. It provides no direct integration, validation, or interaction with a running ComfyUI instance.
- gotcha The internal content of specific templates (e.g., node configurations, connections) can be updated between package versions. This might subtly alter the behavior of your workflows if you depend on a precise template structure.
Install
-
pip install comfyui-workflow-templates
Imports
- get_workflow_template
from comfyui_workflow_templates import get_workflow_template
- list_templates
from comfyui_workflow_templates import list_templates
- comfyui_workflow_templates (as cwt)
import comfyui_workflow_templates as cwt
Quickstart
import comfyui_workflow_templates as cwt
import json
# List all available templates
print("Available templates:", cwt.list_templates()[:5], "...")
# Get a specific template by name (e.g., 'sdxl_base_workflow')
# Note: Template names can change; check available_templates if unsure.
try:
template_name = "sdxl_base_workflow" # This is an example, verify with list_templates()
workflow_json = cwt.get_workflow_template(template_name)
print(f"\nSuccessfully loaded template '{template_name}'.")
# print(json.dumps(workflow_json, indent=2))
print(f"Template keys (top-level): {list(workflow_json.keys())}")
except KeyError as e:
print(f"\nError: Template '{template_name}' not found. Available templates might have changed.")
print("Consider using `cwt.list_templates()` to see current names.")