ComfyUI Node

Random Path

Random Path is misnamed — it hands you an integer. Here's why that's fine

By wenchengxiang·Created about a month ago·Updated a day ago· 1
Random Path
    • path
    模式random
    custom_path0

    Let's be direct about Random Path, because the name is a lie and you should know before you wire it in: despite the "Path" in the title and the path label on the output, this node does not touch files, folders, or directories. It outputs an integer. In random mode it hands you a random number from 0 up to about 1.1 quadrillion; in custom mode it hands back exactly the number you typed in the custom_path box. That's the entire node.

    So what's going on? This looks like a half-converted workhorse that shipped before it was finished - a random-file-picker whose file-listing half never got written. The output type is INT, not a string path, so it can't actually point a loader at a file by name. What it can do is serve as a very large random index, and that's the honest use: pick a random position to select from a numbered list, choose a random seed-like big number to feed another node, or add a genuinely randomizing element to a workflow that otherwise caches its results.

    There's a useful implementation detail hiding here, and it's the reason this node is worth knowing even in its current shape. Its IS_CHANGED method returns a fresh random value every execution in random mode, which is the standard "always rerun" trick from the plumbing layer - the node refuses to be cached. That means every run, the downstream branch it feeds will re-execute. If you want a true "roll something new each time" source that ComfyUI can't skip, this does the job. (The cost is the usual one: a permanently-dirty node poisons caching for everything behind it.)

    How it works

    Two fields in, one integer out.

    • 模式 - the mode dropdown, and yes, that's the Chinese word for "mode" (it's the one non-English label in this pack, left over from the author's own workflow). Choices: random or custom. Random rolls a new integer each run; custom returns whatever's in custom_path.
    • custom_path - the "custom" value. It's typed as an INT widget, default 0, max around 2^50.
    • path (output) - the resulting integer.

    In random mode the source uses random.randint(0, 1125899906842624), so you can land on a truly enormous number - useful if the downstream consumer treats it as an opaque random token rather than a meaningful index. In custom mode it's just a pass-through of your typed value, and because the change-detection uses the fixed input value, a custom config caches normally instead of rerunning every time.

    How to install it

    Ships in ComfyUI-Practical-Tools by wenchengxiang. ComfyUI Manager → search ComfyUI-Practical-Tools → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools
    

    Nothing to download, no requirements beyond the standard library.

    Common issues

    • Expecting an actual file path. The single biggest gotcha. If you came here looking for a "pick a random file from a folder" node, this isn't it - it's a big random integer. You'll need a folder-listing/random-selection combo from another pack instead.
    • "Why does everything downstream rerun every time?" Because random mode's change-detection always reports changed. If the rerun behavior is annoying you, switch to custom mode, or be deliberate about only pointing this at the branch you actually want to re-roll.
    • The Chinese label can confuse searches. If you can't find the field, look for the dropdown with random/custom - that's the mode switch, whatever it's labeled.
    CategoryPractical-Tools/utils

    Inputs (2)

    NameTypeDefaultDescription
    模式COMBOrandom2 options: random, custom
    custom_pathINT00–1125899906842624

    Outputs (1)

    NameTypeDescription
    pathINT