Nodes/ComfyUI-LogicUtils/Pyobjects/Global Var Set
ComfyUI Node

Pyobjects/Global Var Set

Stash a value under a key to use elsewhere in the graph

By aria1th·Created 3 years ago·Updated 7 months ago· 116
Pyobjects/Global Var Set
  • value
  • *
keymy_key

Stores a value under a name so you can pull it out somewhere else without running a wire across the whole canvas. You give it a key and a value, it stashes the value under that key in a shared store, and a matching get node elsewhere reads it back. It's the "teleport a value across a big graph" trick - the same idea as the get/set nodes people love in rgthree and Anything Everywhere, implemented here as a plain global variable.

The appeal is obvious once your workflow gets large. Instead of dragging a single wire from one corner to the far side - through a dozen other nodes, impossible to follow - you set the value once and get it wherever you need it. Prompts, dimensions, filenames, a shared seed: anything you'd otherwise route the long way. It keeps a sprawling graph readable.

How it works

The node writes your value into a global dictionary keyed by the string you give it, living in the running ComfyUI process. It's an output node, so it executes when you queue - and it also passes the value through on its own output, so you can chain it inline as well as read it elsewhere. The output is the wildcard *, matching whatever type you stored.

The inputs that matter

  • key (default my_key) - the name you file the value under. Whatever reads it back must use the exact same key, so pick something distinctive and consistent.
  • value (default my_value) - the thing to store, on the flexible * input. Wire in a string, a number, an image, whatever you need to reach across the graph.

Output is the value again on the wildcard * slot.

The footgun - read this

Global state is powerful and it bites. Because the store lives in the process and is keyed by name, a few things can surprise you. Execution order matters: the value must be set before it's read in a given run, and ComfyUI's graph execution doesn't guarantee that ordering unless your wiring forces it - so a get node can read a stale value from a previous run. And because it's genuinely global, reusing the same key in two workflows, or two spots in one workflow, means they stomp on each other. Values persist across runs until overwritten and reset on a ComfyUI restart.

Translation: use distinct, deliberate key names, make sure the set genuinely happens before the get (chain them if you have to), and don't lean on it for anything where a stale or cross-contaminated value would quietly corrupt your output. For simple cases it's a lifesaver; treated carelessly it's a source of ghost bugs.

Installing ComfyUI-LogicUtils

ComfyUI Manager: Install Custom Nodes → search "ComfyUI-LogicUtils" → install → restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/aria1th/ComfyUI-LogicUtils

Restart ComfyUI. No dependencies.

Worth knowing

The pack is aria1th's (AngelBottomless) undocumented utility collection. This is one of its more advanced nodes and the one most likely to cause head-scratching, precisely because global variables behave differently from the pure input-to-output flow the rest of ComfyUI runs on. Keys unique, set-before-get, and mind that the state is per-process - get those three right and it's a clean way to untangle a big graph.

CategoryData

Inputs (2)

NameTypeDefaultDescription
keySTRINGmy_key
value*my_value

Outputs (1)

NameTypeDescription
**