The Concept
What is ComfyUI?
ComfyUI is an open-source node-based visual workflow editor for stable diffusion and generative models. It lets you design generative pipelines by connecting nodes on a canvas — no code required for the workflow itself.
Key Properties
| Property | Value |
|---|
| Type | Node-based visual workflow editor |
| License | GPL-3.0 (open-source) |
| GitHub | 60k+ stars |
| Models | SD1.5, SDXL, SD3, FLUX, video, audio |
| API | REST + WebSocket |
| Custom nodes | 10,000+ community nodes |
| Deployment | Local, Docker, cloud (RunPod, fal.ai) |
Core concepts
Nodes (Operations)
A node is a single operation in the pipeline — like a function call:
LoadCheckpoint → CLIPTextEncode → KSampler → VAEDecode → SaveImage
Each node has:
- Inputs: data coming in (left side)
- Outputs: data going out (right side)
- Widgets: parameters you can set (prompt text, seed, steps, etc.)
Edges (Data Flow)
Edges connect node outputs to node inputs — they define data flow:
[LoadCheckpoint].MODEL → [KSampler].model
[LoadCheckpoint].CLIP → [CLIPTextEncode].clip
[CLIPTextEncode].CONDITIONING → [KSampler].positive
Graphs (Workflows)
A graph is the complete set of nodes and edges — the entire pipeline. ComfyUI saves graphs as JSON files that can be shared, version-controlled, and executed via API.
Key node types
1. Load Checkpoint
Loads a model checkpoint (.safetensors file):
Node: CheckpointLoaderSimple
Inputs: (none)
Widgets: ckpt_name (dropdown of available checkpoints)
Outputs: MODEL, CLIP, VAE
2. CLIP Text Encode
Encodes a text prompt into conditioning (embeddings):
Node: CLIPTextEncode
Inputs: clip (from LoadCheckpoint)
Widgets: text (your prompt)
Outputs: CONDITIONING
3. KSampler
The core sampling node — runs the diffusion process:
Node: KSampler
Inputs: model, positive, negative, latent_image
Widgets: seed, steps, cfg, sampler_name, scheduler, denoise
Outputs: LATENT
4. VAE Decode
Decodes a latent into a pixel-space image:
Node: VAEDecode
Inputs: samples (latent), vae
Outputs: IMAGE
5. Save Image
Saves the generated image to disk:
Node: SaveImage
Inputs: images
Widgets: filename_prefix
Outputs: (none — saves to file)
What is the correct data flow for a basic text-to-image ComfyUI workflow?
Correct flow: LoadCheckpoint (loads MODEL, CLIP, VAE) → CLIPTextEncode (encodes positive and negative prompts using CLIP) → KSampler (runs diffusion sampling using MODEL, positive/negative conditioning, and an empty latent) → VAEDecode (converts latent to pixel image using VAE) → SaveImage (saves to disk). Each node's output feeds the next node's input.
Canvas UI
Basic Operations
| Action | How |
|---|
| Add node | Double-click canvas or right-click → Add Node |
| Connect nodes | Drag from output dot to input dot |
| Disconnect | Right-click edge → Remove link |
| Delete node | Select + Delete key |
| Execute | "Queue Prompt" button |
| Save workflow | Save button → exports JSON |
| Load workflow | Load button → imports JSON |
Two JSON Formats
ComfyUI has two JSON formats:
- UI format (canvas save): includes positions, widget values, visual metadata
- API format (export): minimal JSON for programmatic execution — this is what you use with the API
# API format example (what you POST to /prompt endpoint)
{
"3": {
"class_type": "KSampler",
"inputs": {
"seed": 12345,
"steps": 20,
"cfg": 8,
"sampler_name": "euler",
"scheduler": "normal",
"denoise": 1.0,
"model": ["4", 0], # Reference to node "4", output 0
"positive": ["6", 0], # Reference to node "6", output 0
"negative": ["7", 0], # Reference to node "7", output 0
"latent_image": ["5", 0] # Reference to node "5", output 0
}
}
}
Installing ComfyUI
# Clone the repository
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
# Install dependencies
pip install -r requirements.txt
# Run
python main.py
# Opens at http://127.0.0.1:8188
Model Placement
ComfyUI/
├── models/
│ ├── checkpoints/ # .safetensors files (SD1.5, SDXL, FLUX)
│ ├── loras/ # LoRA files
│ ├── vae/ # VAE files
│ ├── controlnet/ # ControlNet models
│ └── embeddings/ # Textual inversion embeddings