Nodes/comfyui-yanc/Get Widget Value String
ComfyUI Node

Get Widget Value String

Pull Any Widget's Value Without Rewiring Your Graph

By ka-puna·Created 3 years ago·Updated 11 months ago· 12
Get Widget Value String
    • STRING
    node_name_for_sr
    widget_name

    You've got a seed, a checkpoint name, or a sampler setting sitting in a widget on some node halfway across your graph, and you want that value stamped into a filename or shown on a text overlay. The obvious way is to convert that widget into an input and run a wire across your whole canvas. Get Widget Value String skips the wire.

    It works by piggybacking on a property ComfyUI already has: right-click any node, open its Properties Panel, and there's a field called "Node name for S&R." It's normally there so filename templates like %node_name.widget_name% can find the right node when you type them into a Save Image filename prefix. This node reads that same property directly instead - set it on the node whose value you want (something memorable, doesn't have to match the node's title), type that exact same string into node_name_for_sr, tell it which widget with widget_name, and it hands the value back as a plain string, resolved for the run that's actually queued. So if a KSampler's seed is set to randomize, you get the number that was actually used for that generation, not whatever happened to be sitting in the box beforehand.

    Inputs/outputs. node_name_for_sr (required STRING, default empty) and widget_name (required STRING, default empty) in; one STRING out. Both fields are exact-match, case-sensitive strings - there's no dropdown, no autocomplete, you're typing them by hand. Get either one wrong and the node raises a clear error rather than silently returning nothing: NameError: Node not found if no node's "Node name for S&R" matches what you typed, or Widget not found if the node matched but doesn't have a widget by that name - both messages include the full node_name.widget_name you asked for, which at least tells you exactly what to go check.

    This is the node that makes the rest of yanc's string toolkit actually interesting rather than just decorative. On its own it's a lookup; piped into Concatenate Strings, Truncate String, and eventually Save Image as WEBP's filename_prefix, it's how you stamp real generation parameters - seed, checkpoint, sampler - into your output filenames without hand-typing them or trusting ComfyUI's built-in %…% template syntax to do it for you.

    Installing it. Through ComfyUI Manager: search "comfyui-yanc," install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ka-puna/comfyui-yanc
    

    then restart ComfyUI. No extra Python dependencies, no models - it's part of a deliberately minimal pack (the author's own framing is wanting one small node instead of a whole bloated repo, and nodes simple enough that a ComfyUI update doesn't quietly break them).

    Troubleshooting. The single most common miss: people set the node's title (the text on the title bar) and expect that to be what this node matches against. It isn't. "Node name for S&R" is a separate field inside the Properties Panel, and on some ComfyUI skins the Properties Panel is hidden until you toggle it on from the right-click menu. If you're getting "Node not found" and you're sure you set the property, double-check you didn't just rename the title instead. If two nodes end up sharing the same "Node name for S&R" string, only one of them gets matched - keep the names unique per graph, especially in workflows built from copy-pasted node groups where duplicate properties are an easy accident. And remember widget_name is the internal name ComfyUI uses (things like seed, steps, ckpt_name), not necessarily the label printed next to the widget - if in doubt, that's worth confirming against the node you're targeting before assuming this node is broken.

    Categoryutils

    Inputs (2)

    NameTypeDefaultDescription
    node_name_for_srSTRING
    widget_nameSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING