Nodes/WAS Node Suite v3/Widget to String
ComfyUI Node Runs on cloud

Widget to String

Steal any node's widget value into text

By WASasquatch·Created 3 years ago·Updated 4 days ago· 1,844
Widget to String
    • string
    • found
    node_id
    widget_name
    default

    You want your filename to include the seed that made the picture, or your caption to record which sampler and CFG actually ran. The natural instinct is to re-type those into a text node - which works right up until you change the seed and forget to update the filename, and now your files lie to you.

    Widget to String exists so the filename can read the truth off the node that owns it. You point it at another node in the graph by id, name the widget, and it answers what that widget currently holds, written out as text - 42, 8.0, true, dpmpp_2m, or a whole prompt. No wire touches the node being read. It stays exactly where it is, its seed stays a widget, and this node just borrows the value at run time.

    It slots straight into a filename-prefix flow: read seed off the KSampler, read steps and sampler_name off the same node, join them with a text node, and feed the result into your save node's filename prefix. Every saved PNG now names its own parameters, and the names can't drift because there's only one place the values live.

    What you set

    • node_id - the number on the node's badge, as ComfyUI draws it (12, 37…). No number showing? Turn badges on under Settings. Inside a subgraph the local number works, and a full path like 12:3 does too.
    • widget_name - spelled exactly as the node spells it: seed, steps, cfg, sampler_name, ckpt_name, text. If you misspell it, the error message tells you which of the graph's nodes do carry a widget by that name - genuinely helpful, not a wall of shame.
    • default - optional text to answer when the node or widget can't be found. Give it a value and the prompt keeps running, with found flipping to false so a switch downstream can handle the stand-in. Leave it empty and a miss stops the prompt with a clear message instead. Choose your poison: silent fallback that keeps the run alive, or a loud stop that tells you your node id drifted.

    Outputs

    string is the widget's value as text, ready for a text join, a filename prefix, a console line. found is a BOOLEAN - true when the widget was actually read, false when default stood in - because the string alone can't tell you the difference, and sometimes a placeholder filename is worse than no filename.

    The mechanism is worth knowing because it affects how you debug it: this node reads the queued graph at run time, and it deliberately re-reads every prompt rather than serving from cache. Change the seed on the KSampler, hit queue, and the filename updates. That's the behavior you want here.

    Two honest gotchas

    An input that's filled by a wire, not a widget, holds nothing to read. Widget to String will tell you which node is feeding it, but the takeaway is that it reads widgets - if the value arrives on a cable, convert it somewhere and read that instead. And a widget that has no bearing on the run is one thing, but remember the classic ComfyUI seed trap: with control_after_generate on randomize, the seed in the box is the one used next, not the one that just ran. Read the seed off the node and you're reading the box; that's a ComfyUI behavior, not this node's bug.

    Install

    In WAS Node Suite v3 - ComfyUI Manager, search "WAS Node Suite v3", or

    cd ComfyUI/custom_nodes
    git clone https://github.com/WASasquatch/was-node-suite-comfyui
    

    restart, done. Requires ComfyUI 0.14.0+ / Python 3.10+, no extra packages, no feature flag. It's one of those quiet utility nodes you'll forget exists until a workflow makes you hand-type a seed into three different places - and then it's exactly the node you wanted.

    CategoryWAS Suite/Utilities

    Inputs (3)

    NameTypeDefaultDescription
    node_idSTRINGThe id of the node to read, as ComfyUI draws it on the node's badge: 12. Turn the badge on under Settings if no number is showing. Inside a subgraph the local number is enough, and a full path such as 12:3 works too.
    widget_nameSTRINGThe widget to read, spelled exactly as its node spells it: seed, steps, cfg, sampler_name, ckpt_name, text. An input filled by a wire holds no widget value, and asking for one says which node feeds it.
    defaultoptSTRINGText to answer when the node or the widget cannot be found, which keeps the prompt running and sets found to false. Left empty, a miss stops the prompt with a message naming what was looked for and which nodes do carry a widget of that name.

    Outputs (2)

    NameTypeDescription
    stringSTRINGWhat the widget holds, written out: 42, 8.0, true, dpmpp_2m, or a whole prompt. Feed it to a filename prefix, a text join, or anything else taking a STRING.
    foundBOOLEANtrue when the widget was read, false when default stood in for it. Wire it into a switch where a stand-in must be handled differently, since the string alone cannot tell the two apart.