ComfyUI Node

Prompt Router

The switcher that reads its own wires — route between connected prompts

By relhamdi·Created 7 months ago·Updated 2 months ago· 1
Prompt Router
    • text
    • index
    selected--
    _sub_selected--
    _value_selected--
    input_0
    input_1
    input_2
    input_3
    input_4
    input_5
    input_6
    input_7
    input_8
    input_9

    Every ComfyUI workflow eventually needs the same thing: "I want to flip between these three prompts without re-wiring the graph." The naive version is a text input you manually overwrite, which is exactly how you end up with three workflows when one would do. PromptRouter is the proper answer - up to 10 string inputs, one dropdown, and it intelligently names the choices for you.

    The trick that makes it good

    Most switch nodes make you label your inputs by hand. PromptRouter doesn't need to, because it inspects the actual graph at runtime. Connect a node called "position", another called "background", and the dropdown fills itself with 0: position, 1: background, 2: lighting - the title of each connected source node, prefixed by its index. Rename a node and the dropdown updates; disconnect one and it disappears. It even survives save/reload and undo/redo, since the selection is stored in the workflow.

    On execution it outputs the selected input's text plus its index (useful if you want to drive other logic with the choice). If a connected node is bypassed, the output is an empty string rather than an error.

    The inputs and outputs

    • selected - the dropdown itself. The internal _sub_selected and _value_selected fields are wiring for the advanced features below; you don't touch them.
    • input_0 through input_9 - connectable STRING inputs, revealed one at a time as you fill them.
    • Outputs: text (the routed value) and index (the 0-based slot number).

    Sub-routers and deep integration

    This is where PromptRouter gets clever. If one of the connected sources is another PromptRouter, it's marked with a and selecting it reveals a second dropdown listing the child's options. Parent and child stay in sync both ways, and multiple parents sharing one child all update together. Sub-routing is limited to one level deep, which is honestly enough.

    Even better, when a connected source is a PromptOptionPicker, PromptLayoutFiller, or PromptPresetSelector, it gets a marker, and selecting it reveals a third dropdown populated from that node's own options or presets. Change the picker's selection and the router reflects it; change it in the router and it pushes back into the source node. It works through one level of sub-router too, so you can build a whole control panel out of routers and pickers.

    Installing it

    It's part of ComfyUI-RE-CustomUtils. ComfyUI Manager → search the pack, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/relhamdi/ComfyUI-RE-CustomUtils
    

    Restart ComfyUI. No extra dependencies to pip install, no models to fetch.

    Known quirks worth knowing

    The author documents two gotchas, and both are real:

    • Getters. If you connect a value-getter node (the invisible kind that just retrieves a setter's value) to the router, the getter's name appears in the dropdown but the router reads the wrong node and hands you an empty string. The fix: link the getter through an ordinary string node before connecting it to the router. It's a one-node workaround once you know it.
    • Stale sub-router lists. If a child router's connections change while it's selected in the parent, the parent's dropdown may lag until you reconnect or touch it. Annoying, but a refresh is one click away.

    For a beginner the / indicator system takes a minute to click, but it's the difference between a bare switch and a real prompt-selection control surface. That's what you're paying for here.

    CategoryRE-CustomUtils

    Inputs (13)

    NameTypeDefaultDescription
    selectedSTRING--Select the active input.
    _sub_selectedSTRING--Internal use only.
    _value_selectedSTRING--Internal use only.
    input_0optSTRING
    input_1optSTRING
    input_2optSTRING
    input_3optSTRING
    input_4optSTRING
    input_5optSTRING
    input_6optSTRING
    input_7optSTRING
    input_8optSTRING
    input_9optSTRING

    Outputs (2)

    NameTypeDescription
    textSTRING
    indexINT