Nodes/comfy-ovum/os.path.expanduser
ComfyUI Node

os.path.expanduser

Turn ~ into your real home folder — os.path.expanduser as a node

By sfinktah·Created about a year ago·Updated 10 months ago· 7
os.path.expanduser
  • path_in
  • path
path
forward_slashesfalse

Ovum Os Path Expanduser wraps os.path.expanduser, and it exists to solve one specific annoyance: paths that start with ~. On Unix-like systems ~ means your home directory, and it's a great shorthand in a terminal - but ComfyUI nodes generally want concrete absolute paths, and a ~ sitting in a string will confuse any loader or saver that doesn't expand it. This node expands ~ and ~user constructions into the real home directory path.

When would a ~ even get into your graph? If you build paths from a config value, an environment bridge, or text typed into a widget - ~/models/loras/my_lora.safetensors is exactly the kind of string a human writes without thinking. Run it through this node and it becomes /home/you/models/loras/my_lora.safetensors, ready for anything downstream. Pair it with abspath to also resolve relative segments in the same breath.

How it works

Straight os.path.expanduser() delegation via the family's shared base. A path widget plus an optional path_in jack (PATHLIKE,STRING) that overrides the widget when connected. On Unix, a leading ~ alone expands to the current user's home; ~username expands to that user's home; ~+ expands to the current working directory (a shell-ism Python supports). On Windows it uses USERPROFILE, so ~ becomes your user profile folder. The forward_slashes toggle normalizes separators in the result.

The inputs and outputs that matter

  • path (required, STRING) - the path to expand.
  • path_in (optional, PATHLIKE,STRING) - wired alternative to the widget.
  • forward_slashes (BOOLEAN, default false) - normalize separators in the output.
  • path (output, STRING) - the expanded path.

Installing it

In 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. No models to download; the pack's dependencies are light and Manager handles them.

Common issues

The edge cases are all in the tilde rules. A ~ in the middle of a path is left untouched - only a leading one is special. ~nonexistentuser won't expand on Unix (it's left as-is), and ~ with no username on Windows expands via USERPROFILE, which may not be what you expected if the server runs as a service account. And remember this doesn't check existence - a ~ pointing at a home dir that doesn't exist on the server machine expands happily into a bogus path. The expansion happens relative to whatever user the ComfyUI process runs as, not your browser's user.

Categoryovum/path/os.path

Inputs (3)

NameTypeDefaultDescription
pathSTRING
forward_slashesBOOLEANfalse
path_inoptPATHLIKE,STRING

Outputs (1)

NameTypeDescription
pathSTRING