๐พ๐ ฐ๏ธ Save Global Variables
Persist a value across separate workflow runs
- connect_to_workflow
Normal ComfyUI variables live inside a graph - connect a node's output to another node's input, and that's the whole scope of the value. This node steps outside that: it writes text to a plain file on disk (Bjornulf/GlobalVariables.txt by default, inside your ComfyUI folder), so a value can survive between completely separate runs, or even be read by a different workflow entirely. It's the save half of a pair - the pack's Load Global Variables node reads it back - and it's the closest thing this node pack has to a persistent variable outside the graph.
How it works
You feed it a block of text and choose append or overwrite. Append is the default, and it tacks your new text onto whatever's already in the file rather than replacing it - useful for building up a running list (character names you've used, seeds you've liked, whatever) one run at a time. Overwrite does what it says, wiping the file and starting fresh with just what you sent this time. The optional filename field lets you split off into a separate, named global-variable file instead of writing to the shared default - handy if you don't want your "character list" variables and your "scene settings" variables landing in the same file and getting tangled.
Because the file lives on disk in your ComfyUI folder rather than inside the graph's memory, you can also just open it and edit it by hand if you want to fix or prune something without re-running a workflow.
The inputs and outputs that matter
variables(STRING, multiline) - the text you want to save.mode(enum:append/overwrite, defaultappend) - whether to add to the existing file or replace it entirely.filename(STRING, optional) - set this to write to a separate named file instead of the shared defaultGlobalVariables.txt.- Output:
connect_to_workflow(STRING) - a passthrough so you can keep this node inline in your graph without breaking the flow into whatever comes next, rather than it being a dead-end.
How to install it
Via ComfyUI Manager: search Bjornulf_custom_nodes, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/justUmen/Bjornulf_custom_nodes
cd Bjornulf_custom_nodes && pip install -r requirements.txt
then restart ComfyUI. Nothing special this node needs beyond the shared pack requirements - it's plain file I/O, no models, no heavy libraries.
Common issues & troubleshooting
Append mode grows the file forever. If you leave mode on append and run the workflow a hundred times, you get a hundred entries in the file - that's by design, but it means the file can get long fast if you're not periodically switching to overwrite or manually trimming it.
Wrote to the default file when you meant a separate one. Leaving filename blank writes to the shared Bjornulf/GlobalVariables.txt. If you're managing more than one category of persistent value, set a distinct filename per category early, before the default file becomes a mess of unrelated entries.
Two workflows racing on the same file. This node isn't doing any locking - it's a straightforward file append/overwrite. If you're running multiple workflows against the same global-variable file back to back rather than in true parallel, you're fine; genuinely simultaneous writes from two running graphs are the one case worth avoiding.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| variables | STRING | โ | |
| mode | COMBO | append | 2 options: append, overwrite |
| filenameopt | STRING | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| connect_to_workflow | STRING | โ |