flow_workflow_save_gate
Archive the workflow, or strip it from every image you save — one switch
- anydata
- anydata
Every ComfyUI PNG is secretly a project file: the full node graph gets written into the file's text chunks, which is why drag-and-drop recovery works and why posting a render online hands strangers your prompt, your workflow and your LoRA names. Most people deal with this by remembering to use a different node in the "private" branch, or by re-encoding the file afterwards - which throws away quality to remove data.
flow_workflow_save_gate does it properly. It's a pass-through node: the anydata you feed in comes straight back out, so you drop it inline in a chain rather than at the end. What it actually does depends on one boolean.
The mechanism, because it's clever
Flip save_workflow off and the node does not just stop saving. On queue, a prompt handler installed by the pack walks the graph forward from every gate that's switched off - following wires, transitive closure and all - and rewrites any core SaveImage node it reaches to a different class, flow_workflow_save_image_no_metadata, which saves the same pixels with the metadata arguments nulled out.
So the same workflow can run one branch that archives itself and another that produces postable files, selected by a checkbox at queue time rather than by keeping two copies of your graph in sync. No re-encoding, no quality loss, no third-party metadata stripper.
Flip it on and the node dumps the current front-end workflow as JSON into save_directory, named workflow_name + an underscore + a microsecond timestamp - so portrait_run_20260916_141233_481920.json. It writes to a .tmp first and then renames, so a crash mid-write doesn't leave you a truncated workflow.
Inputs and output
- anydata - a
*input, so it accepts anything. Types in ComfyUI aren't enforced for wildcards; the node passes the object straight through untouched. - save_workflow - the switch. The node's own labels describe it well: on means "save and pass", off means "pass without the workflow".
- save_directory - where the JSON goes. Defaults to your ComfyUI output directory, and there's a folder-picker button on the node itself so you don't have to type a path.
- workflow_name - the filename prefix. It refuses illegal filename characters, and strips a trailing
.jsonif you paste one in.
Output is anydata, the same object you put in. Because the node is marked as an output node and its change-check returns float("nan"), it re-runs on every queue - which is what you want for a "save a fresh copy each run" node, and is also the thing that defeats caching for anything downstream of it. Keep it near the end of a branch.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset
cd ComfyUI-Apt_Preset
pip install -r requirements.txt
Restart, and the node shows up under Apt_Preset/flow. No extra models, nothing heavy - but the pack's requirements.txt is long, so if you only want this node you'll still be installing PySceneDetect, OpenCV, onnxruntime and friends. Via ComfyUI Manager, search Apt_Preset.
Where it bites
The stripping is done by graph traversal at queue time, which means it only catches nodes whose class is literally SaveImage. If you save through a custom node from another pack - a video saver, an image-saver with a different name, a WebP encoder - the gate will pass it by without touching it and your metadata goes out the door anyway. Same for anything upstream that embeds data itself.
The other failure modes are all the honest kind. Queue through the API instead of the UI and there's no front-end workflow to save, so the node raises "no frontend workflow data in this queue" rather than silently writing an empty file. Point save_directory at a folder that doesn't exist and it errors instead of creating one - that's deliberate, but it does mean a workflow that worked yesterday breaks when you move your output folder.
One philosophical note, because it's the thing this pack is built on: gating is a property of a branch, and branches in a context-heavy workflow are easy to lose track of. If your images come out with metadata after you switched the gate off, check what's actually downstream of the gate's output - the traversal only reaches nodes wired to it.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| anydata | * | — | |
| save_workflow | BOOLEAN | true | 开启时保存当前工作流并放行数据;关闭时移除下游图片的工作流元数据并放行数据。 |
| save_directory | STRING | /tmp/ComfyUI/output | 工作流JSON保存文件夹,可用节点上的按钮选择。 |
| workflow_name | STRING | workflow | 工作流文件名前缀,保存文件名为 前缀_时间戳.json。 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| anydata | * | — |