Get Environment Variable
Read machine settings from inside a workflow (without leaking secrets)
- value
- exists
This node is a thin wrapper around Python's os.environ.get(name, default) - one input for the variable name, one for a fallback, and it hands you back the value. That's the whole thing, and it's more useful than it sounds once you get why a string is the right type for a variable bus.
The use case is configuration that shouldn't live inside your saved workflow. ComfyUI workflows are JSON, and that JSON gets embedded into every PNG you save and every workflow you paste into Discord. If your API key, output directory, or model path is hardcoded in a widget, it's in the file forever. Read it from the environment instead: launch ComfyUI with the variable set, and Get Environment Variable pulls it in at runtime. Sharing the workflow stops leaking your setup.
You'll typically pair it with its sibling Set Environment Variable (SetEnvVar) from the same pack, which writes to the process environment. Together they form a publish/subscribe bus: one node writes OUTPUT_DIR or ACTIVE_CHECKPOINT, and any number of GetEnvVar nodes scattered across the graph read it without a single wire between them. It also works across workflows - two workflows running in the same ComfyUI session can share state through the environment, which is handy for multi-stage pipelines where workflow A saves a path that workflow B picks up.
The inputs that matter
- name - the environment variable to read. Just the name, e.g.
MY_API_KEY. - default - what you get back if the variable isn't set. Leave blank and you'll get an empty string instead of a crash.
Two outputs come out:
- value (STRING) - the value, or your default.
- exists (BOOLEAN) -
trueif the variable was actually set versus you getting the fallback. Wire this into a conditional if "did it fall back?" matters.
A nice detail: the node is change-aware. It hashes the current value and only re-runs when the variable actually changes, so a reader sitting at the end of a long pipeline doesn't force pointless re-execution. The hash also means the node won't print your secrets to the console - the author went out of his way on that one.
Installing it
It ships in comfy-ovum, sfinktah's grab-bag pack. Easiest route:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Then restart ComfyUI, or use ComfyUI Manager and search for "comfy-ovum". No model downloads, and the dependencies are light (requests, pillow, numpy, aiohttp - mostly already in your environment). Note that the pack auto-imports every Python file in its root at startup, so if you see unrelated ovum nodes in your list, that's normal.
Gotchas
Values are always strings - if you need a number, convert downstream. Environment changes only live for the current ComfyUI process; a restart wipes everything you set at runtime. And the namespace is shared with the actual OS environment, so the pack blocks writes to a few dangerous names on the Set side, and it's worth prefixing your own keys (OVUM_) to avoid colliding with a real system variable.
Honestly, if you never have cross-workflow needs and just want one value available in one workflow, a text widget is simpler. Reach for this the moment the value becomes a secret, a machine-specific path, or something two workflows need to agree on.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| name | STRING | Environment variable name to read. | |
| default | STRING | Fallback value if the environment variable is not set. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| value | STRING | — |
| exists | BOOLEAN | — |