π Path Normalize
Clean up the path string before it bites you
- Normalized Path
Paths in ComfyUI arrive from everywhere: a widget you pasted into, a text file you read off disk, a string another node built by concatenation, a workflow someone wrote on a different OS. They arrive with mixed separators, a stray ~, an environment variable that isn't expanded, and a .. in the middle. Path Normalize is the node that takes that mess and hands back one clean string.
How it works
Three operations, in order. First it unifies separators by replacing every backslash with a forward slash - deliberately, before anything else, so the subsequent os.path calls see one consistent shape regardless of what the user typed. Then it runs os.path.expanduser and os.path.expandvars, which expands a leading ~ to the home directory and substitutes environment variables. Then os.path.normpath collapses doubled separators, resolves . and .. segments, and emits the whole thing with the host platform's native separator.
It is a string transformation, and that distinction matters more than it sounds:
- It does not check that the path exists.
- It does not resolve symlinks (that would be
realpath). - It does not make relative paths absolute - nothing here consults the current working directory, so
output/foo.pngstays exactly that. ..gets resolved lexically, which is fine for cleaning up a path and wrong if a symlink is involved. Rarely your problem; worth knowing.
The environment-variable expansion has a platform split you can trip over. On Windows, os.path.expandvars understands both %USERPROFILE% and $USERPROFILE. On Linux and macOS it only understands the $VAR and ${VAR} forms - a Windows-style %USERPROFILE% in a path arrives completely unexpanded. If you're moving a workflow between platforms, prefer ~.
The inputs and outputs that matter
One input, Path - a single-line STRING, and the tooltip correctly promises it takes forward slashes, backslashes, or the mixed horror in between. One output, Normalized Path, which is the cleaned STRING. Empty in, empty out (no error).
Where it earns its place: in front of anything that consumes a path as data. A path read from a text file with Read File, a destination assembled by a node that isn't path-aware, a value that came in from an environment you don't control. Drop Path Normalize in the chain and the node behind it gets something it can actually open.
The subtler use is portability. Because it emits host-native separators, the same graph works whether the string it was handed used Windows or POSIX conventions - pair it with Path Join (which builds fresh paths from segments) and you've got both directions covered: Join for constructing, Normalize for cleaning up what someone else made.
Empty input returns "" rather than throwing, so if you're debugging "why does this node get an empty path", put a Text Preview on the normalizer's output and you'll see immediately whether the problem is upstream or downstream.
How to install it
Part of Avaray/honda-nodes - ComfyUI Manager β Node Pack β search Honda Nodes β Install β restart. Manual:
cd ComfyUI/custom_nodes
git clone --depth 1 https://github.com/Avaray/honda-nodes.git
cd honda-nodes
python install.py
Nothing in the installer is required for this specific node (stdlib only), but it fetches the jq and ime binaries the rest of the pack depends on. No pip packages, no model files.
Common issues
~ didn't expand the way you expected. It only expands at the start of a path - /data/~backup/ contains no home directory, it's just a folder with a tilde in the name. And on Windows, ~ expands to the profile directory Python thinks you have, which under a portable install or a service account may not be the folder you're looking in.
A %SOMETHING% variable survived untouched. Linux/macOS don't do %VAR%. Use $SOMETHING.
The path looks fine but the file still isn't found. Normalize can't fix a path that's correct on paper but points at a folder that doesn't exist, or that's relative to the wrong working directory. If you're not sure what a relative path will resolve against, make it absolute yourself in the graph rather than hoping.
Trailing separator disappeared. normpath strips it. If something downstream genuinely needs dir/ with the slash, append it after the normalizer with Text Concatenate - and if that sounds annoying, it's because it is: almost nothing needs a trailing slash once you're talking to Python's file APIs.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | Raw path string to normalize. Accepts forward slashes, backslashes, or mixed separators. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Normalized Path | STRING | β |