os.path.expandvars
Resolve $VAR and ${VAR} inside your paths — os.path.expandvars
- path_in
- path
Ovum Os Path Expandvars wraps os.path.expandvars, the standard-library function that replaces $name and ${name} inside a string with the corresponding environment variable values. It's the node you reach for when a path (or any string) contains environment variables that need resolving before it's usable - think $HOME/models/lora.safetensors or %USERPROFILE%\output on Windows, where $HOME and %USERPROFILE% are meant to become real directories.
This is a natural partner for the pack's environment bridge nodes (Set/Get Environment Variable). If you publish an OUTPUT_DIR via SetEnvVar and later build a filename string containing $OUTPUT_DIR, this node turns that placeholder into the actual path at execution time. It's also just handy for resolving variables that ComfyUI's own process inherits from the OS - $TEMP, $HOME, $PATH-style references buried in user-supplied strings.
How it works
Pure os.path.expandvars() delegation through the family's shared base: a path widget and an optional path_in jack (PATHLIKE,STRING) that wins when connected. On Unix it expands $name and ${name} (and the shell's $name form); on Windows it also handles the %NAME% style. Undefined variables are left literally in place - no error, just an unexpanded placeholder. The forward_slashes toggle normalizes separators after expansion.
The inputs and outputs that matter
- path (required, STRING) - the string with variables to expand.
- path_in (optional, PATHLIKE,STRING) - wired alternative to the widget.
- forward_slashes (BOOLEAN, default false) - normalize separators in the result.
- path (output, STRING) - the expanded string.
Installing it
Part of comfy-ovum (sfinktah). ComfyUI Manager: search "comfy-ovum", install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Restart after cloning. No models, no heavy dependencies - the pack's requirements are light and Manager installs them.
Common issues
The undefined-variable behavior is the one to internalize: misspelled or unset variables don't error, they stay as literal text - $OUTPU_DIR silently survives into the output and downstream code fails on a path that literally contains $OUTPU_DIR. On Unix, $name expansion is greedy about what counts as a variable name, so $OUTPUT_DIR_1 parses as variable OUTPUT_DIR_1, not OUTPUT_DIR plus _1 - use the ${...} braces when a variable is followed by non-separator characters. And since the expansion depends on the environment of the ComfyUI process (not your browser), a variable set in your shell but not the server's won't resolve.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — | |
| forward_slashes | BOOLEAN | false | — |
| path_inopt | PATHLIKE,STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| path | STRING | — |