Env Keys
Dump every secret from your .env straight into the graph
- keys
You've got a workflow with an API key sitting in a text node. You export it to show someone - comfy.icu, Reddit, a Discord thread - and suddenly your key is baked into the JSON, traveling with every share. Env Keys exists so you never have to do that. It reads the .env file in your ComfyUI root and turns every key in it into its own output port, named after the key. No inputs, no keys in the workflow file. Wire the API_KEY port into whatever STRING input needs it, and the value is read fresh at execution time.
It's one half of ComfyUI-Env-Loader, a two-node pack by Boris Hu (hubo502). Env Keys is the "give me everything" variant; its sibling Env Key Selector does the same job one key at a time with a dropdown. If a .env already exists in your ComfyUI setup for other tools, this node turns that same file into live graph data instead of you pasting values around.
How it works
On import, the node walks up from its own directory until it finds a folder containing custom_nodes, then looks for a .env next to it - so ENV_PATH is always <ComfyUI root>/.env, the folder above custom_nodes. It parses that file with a ~30-line hand-rolled parser from the Python standard library. No python-dotenv, no requirements.txt, no dependencies to break your environment. Then it builds its outputs from whatever keys it found: RETURN_NAMES becomes the key list, so the number of ports is fixed at the moment ComfyUI imports the node.
Each run, list_values() re-parses the file and returns the current value for every key, and IS_CHANGED returns the file's mtime so ComfyUI knows to recompute when the file changes. Startup logging prints [Env Loader] Loading env from ... and the key list, which is handy when the ports look wrong.
Inputs and outputs that matter
There are no inputs. Zero. All the action is on the output side:
- One output port per key in
.env, named exactly after the key, allSTRING. - If there's no
.env(or it's empty), you get a single placeholder port namedkeyswhose value is the comma-joined list of keys - ComfyUI's way of showing "here's what I found" instead of nothing.
Everything comes back as a string. DEBUG=true is the literal text "true", not a boolean. That's fine for feeding text inputs; it just won't toggle logic for you.
The trap: ports are frozen at boot
Ports are generated once, at import. Add a key to .env and the new port won't appear until you restart ComfyUI. Delete a key and you get an empty-string value on a stale port rather than the port vanishing. Values refresh live - re-read every execution, mtime-triggered - but the port layout only updates on restart. It's a small annoyance for a utility this size, and it's worth knowing before you blame a "bug" on a missing port.
Install
Via ComfyUI Manager, hit "Install via URL" and paste the repo, or manually:
cd path/to/ComfyUI/custom_nodes
git clone https://github.com/hubo502/ComfyUI-Env-Loader.git
Restart ComfyUI and it appears under Utils. No model files, no heavy deps - the pack is two Python classes, MIT-licensed. Then create .env at the ComfyUI root (the folder that contains custom_nodes, not inside the node's own folder - ComfyUI won't create it for you):
API_KEY=12345
MODEL_PATH="C:/Models"
DEBUG=true
Lines are KEY=VALUE, # comments and blank lines are fine, and single- or double-quoted values get the quotes stripped.
Common issues
- Placeholder
keysport instead of real ones:.envisn't where the node is looking, or the lines have no=. It must sit besidecustom_nodes. - Ports didn't change after editing
.env: restart ComfyUI; the layout is locked at import. - Stale value: re-run the graph -
IS_CHANGEDkeys off mtime, so a touched file should trigger recompute.
This node shines with a handful of keys. If your .env has twenty, the wall of ports gets unwieldy, and that's when you reach for the Selector instead. And one honest caveat: .env keeps secrets out of your shared workflow JSON, but don't zip up your whole ComfyUI folder to hand to a friend - the .env goes with it.
Inputs (0)
No inputs
Outputs (1)
| Name | Type | Description |
|---|---|---|
| keys | STRING | — |