Nodes/hus' utils for ComfyUI/Fetch widget value
ComfyUI Node

Fetch widget value

Steal any node's widget value and use it as text

By hustille·Created 3 years ago·Updated 2 years ago· 5
Fetch widget value
    • STRING
    node_name
    widget_name
    multipleno

    Ever wanted to use the seed that actually ran in your output filename, or drop a KSampler's cfg value into a text note without retyping it? That's what this node is for. Give it a node name and a widget name, and it hands you that widget's current value as a plain string you can wire anywhere a text input goes.

    The name undersells the trick slightly. It doesn't read the UI live - it reads the workflow definition plus the executed prompt at queue time, so what you get back is what actually ran, not what you last typed. The author extracted the idea from the Math Expression node in pythongosssss's ComfyUI-Custom-Scripts, which is a decent pedigree for this kind of plumbing node.

    How it works

    When ComfyUI queues a job, every node receives two hidden inputs: extra_pnginfo (the workflow graph) and prompt (the executed values). This node scans the graph for a node matching node_name, then looks that node's id up in the prompt to pull the widget's value. It marks itself IS_CHANGED to return NaN, which is ComfyUI's way of saying "re-execute me every queue even if my inputs didn't change" - without that, caching would freeze the fetched value at the first run.

    Matching node_name is the fiddly bit. It checks three things, in order: the node's type (the class name, like KSampler or CheckpointLoaderSimple), its "Node name for S&R" property, then its title. So you can point at a node by class, by a title you set, or by an S&R alias - but not by a display name that differs from the class name.

    The inputs that matter

    • node_name - the class name, title, or S&R name of the target node. This is the one you'll get wrong first.
    • widget_name - the widget to fetch, e.g. seed, cfg, steps.
    • multiple - no (default) returns the first match; yes returns all matches joined with ", ".

    Output is a single STRING.

    Where you'd use it

    Pair it with Text Hash to make stable filename prefixes, feed it into a filename template, or pipe a seed into a math/expression node. It's the classic "my workflow shouldn't need me to read numbers off the screen" utility.

    Two gotchas worth knowing. First, if the widget you're fetching is driven by a wire rather than typed in, you'll get a link reference like [3, 0] back instead of a value - it reliably reads typed widget values, not connected inputs. Second, if it can't find a match it raises Node not found: <name>.<widget> in the console; check whether you typed the class name or a title.

    Install

    Via ComfyUI Manager, search "hus' utils" (pack title: hus' utils for ComfyUI). Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/hustille/ComfyUI_hus_utils
    

    Restart ComfyUI. No requirements.txt, no pip install, no model downloads - it's pure standard library plus ComfyUI's own internals, so it's about as safe a custom node as this ecosystem offers.

    Categoryutils/hus

    Inputs (3)

    NameTypeDefaultDescription
    node_nameSTRING
    widget_nameSTRING
    multipleCOMBOno2 options: yes, no

    Outputs (1)

    NameTypeDescription
    STRINGSTRING