Nodes/KJNodes for ComfyUI/Get Workflow KJ
ComfyUI Node Runs on cloud

Get Workflow KJ

Dump the graph that's running, as JSON, from inside the graph

By kijai·Created 3 years ago·Updated 3 days ago· 3,521
Get Workflow KJ
    • json
    ◄formatworkflow►

    What it actually does

    Get Workflow KJ reaches into the queue, grabs the graph that is currently executing, and hands it back to you as a text string. That's it. One combo box, one string output, no model, no VRAM.

    The reason to care is that ComfyUI already attaches both metadata blobs to every prompt it queues: the workflow chunk (your full UI graph - node positions, wires, widget values, muted branches) and the prompt chunk (the flattened execution format the backend actually ran). Normally those only survive if SaveImage writes them into a PNG, and they vanish the moment some host or a re-encoder strips the file. This node puts the same data on a wire, so you can do something else with it: write it to disk every run, log it next to your outputs, shove it into a dataset, feed it to a script that diffs two versions of a pipeline.

    Two formats, and the difference matters more than the combo box suggests:

    • workflow (default) - the UI format. This is the thing you can load back into ComfyUI and get your annotated canvas back, with reroutes, notes and groups intact.
    • api prompt - the API format. Same generation, flattened to node IDs and resolved values, UI-only data stripped. It runs, but it opens as numbered boxes, not the layout you drew.

    If you've ever dragged a PNG into the canvas and gotten a mysterious grid of unnamed nodes instead of the pretty graph, you met the prompt chunk. Same distinction here, on tap.

    How it works

    It doesn't read a file or inspect your canvas. The node declares ComfyUI's hidden prompt and extra_pnginfo inputs, which the frontend stuffs into every queued job, and then just JSON-dumps whichever one you asked for. Under the hood it's the same pair of blobs as in the PNG chunks - extra_pnginfo["workflow"] for the UI graph, the raw prompt for the API form.

    There's one nice detail in the caching. Rather than always re-running or always caching, the node fingerprints the prompt currently being executed, so it re-runs when what executes changes and stays cached when you only moved nodes around. You can nudge a box on the canvas without dirtying the output string.

    Wiring it up

    The only required input is format. The only output is json - a STRING. Feed it to Save String KJ from the same pack with a .json extension (the node's own description recommends exactly that) if you want a file on disk, or to any text display node while you're debugging.

    [yours, whatever] → Get Workflow KJ(json) → Save String KJ(string, file_extension=".json")
    

    A file per run of the exact graph that produced it is genuinely useful when a pipeline is being iterated on by two people, or when you're trying to work out which of eleven workflow variants produced the good image three weeks ago.

    Installing it

    ComfyUI Manager, search KJNodes (pack title "KJNodes for ComfyUI"), install, restart. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/kijai/ComfyUI-KJNodes
    pip install -r ComfyUI-KJNodes/requirements.txt
    

    Portable Windows installs use python_embeded\python.exe -m pip install ... from the ComfyUI_windows_portable folder, as the README spells out. The dependency list is genuinely light - pillow, color-matcher, matplotlib, mss, opencv-python-headless - which is why KJNodes is on most people's must-install list and rarely the pack that breaks your environment. No models, no downloads, nothing to put in models/.

    One thing to know about KJNodes generally: the pack is a grab-bag that tracks ComfyUI closely, and its newer nodes are written against ComfyUI's current node API. Keep ComfyUI itself fresh; an old install is the usual reason a node from this pack won't appear.

    Where people get burned

    Queued through the API, no workflow to give you. If a job arrives without extra_pnginfo - which is what happens when something drives ComfyUI as an API rather than through the browser - the workflow format has nothing to return and the node fails with a message telling you to use api prompt instead. That's correct behavior, not a bug. Switch the combo.

    Expecting the JSON to be small. It's the whole graph, indented. Big workflows produce long strings, so if you're piping this somewhere with a size limit, keep that in mind.

    Assuming the two formats are interchangeable. They're not. Archive the workflow format if you want to reopen and edit later; use api prompt if you want something a script can replay or diff against a previous run. The API form is also the more durable artifact in one sense - it's plain text you can post in a comment - but it loses the thing that made the graph readable.

    CategoryKJNodes/text

    Inputs (1)

    NameTypeDefaultDescription
    formatCOMBOworkflow2 options: workflow, api prompt

    Outputs (1)

    NameTypeDescription
    jsonSTRING—