ComfyUI Node

join

Join path pieces the OS-safe way — no more missing slashes

By StableLlama·Created about a year ago·Updated 4 days ago· 48
join
    • path
    path1
    path2

    Basic data handling: PathJoin ("join") does the one thing everyone ends up doing by hand eventually and getting wrong: sticking path pieces together. Two strings in, one path out, and the separators are handled for you - backslashes on Windows, forward slashes on Unix, no double slashes where the halves meet.

    Why you'll actually use it: because string concatenation in a workflow is a trap. Build "C:\ComfyUI\input" + "\\ref.png" in a text node and you're one wrong slash from a broken path. PathJoin turns that into two clean inputs - PathInputDir feeding path1 and a filename feeding path2 - and produces a correct absolute path that works on whatever OS you're running. It's the glue that makes this pack's PathInputDir and PathGlob outputs usable as full paths.

    How it works

    Under the hood it's Python's os.path.join(path1, path2). Two details from the source worth knowing:

    • It only takes two components. path1 is required, path2 is optional. For three or more, chain two PathJoin nodes together - join the first two, then join the result with the third. It's clunkier than a varargs join, but it works and stays readable.
    • Empty components are skipped. If path2 is "", you get path1 back untouched. So a "maybe there's a subfolder" input can be empty without corrupting the result.
    • os.path.join doesn't normalize the result - it just joins. If you feed in messy pieces with .. or redundant separators, you'll want PathNormalize after to clean up.

    Inputs and outputs

    • path1 (STRING, default "") - the first component (typically the base directory).
    • path2 (STRING, default "", optional) - the second component (typically a filename or subfolder).
    • path (STRING) - the joined result, with the correct separator for your OS.

    Installing it

    Part of Basic data handling, the no-dependency pack. ComfyUI Manager → search "Basic data handling" → install → restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Restart after. No models, no pip.

    Gotchas

    The classic os.path.join surprise: if a later component is absolute (starts with a drive letter or /), Python discards everything before it. So joining "C:\input" with "\ref.png" gives you \ref.png - the base is gone. Feed absolute-looking pieces in and the join silently ignores the base. It's Python behavior, not a bug, but it's the thing most people trip on. Also remember it joins, it doesn't validate - the file doesn't have to exist for the join to succeed. Pair it with PathExists if you need proof before you load. It's the quiet workhorse of the pack, and once you stop typing paths by hand you won't go back.

    CategoryBasic/Path

    Inputs (2)

    NameTypeDefaultDescription
    path1STRING
    path2optSTRING

    Outputs (1)

    NameTypeDescription
    pathSTRING