Nodes/AUN ComfyUI Nodes/Apply Preset To Node
ComfyUI Node

Apply Preset To Node

The node that writes widget values into other nodes — presets that actually stick

By loz2754·Created 8 months ago·Updated a day ago· 5
Apply Preset To Node
    • applied_values
    • applied
    • notes
    node_identifier
    preset_values
    only_widgets
    aliases

    ComfyUI's worst habit is that every setting is a widget trapped on the node it belongs to. Change the CFG and you reach across the canvas to poke the KSampler. Change the seed format and you poke the loader. Apply Preset To Node (AUNApplyPresetToNode) is the fix: it takes a JSON object of widget values and writes them into another node's inputs at queue time - so one control node can drive a whole row of settings on a distant target.

    It's the "muscle" half of AUN's two-node preset system. Its partner Preset Manager (AUNPresetManager) decides which preset row is active and hands over a JSON blob; Apply is the thing that actually makes the target run with those values. You can also feed it JSON from anywhere - a Show Any node, a hand-written block, another pack's output - because at heart it's just "write this dict into that node's inputs."

    How it works

    The clever part is when it applies. When this module loads, it registers an on-prompt handler with ComfyUI's PromptServer. That means the moment you hit Queue, before the prompt is validated or cached, AUN gets the raw prompt JSON and patches the target node's inputs in place. The target then executes with your preset values even on a fully cached re-run - which is the thing that kills naive "Set" nodes, because once a node's inputs hash to a cached result nothing downstream gets a chance to touch it. The node's own execution pass then repeats the write as a fallback and fires a WebSocket event so the target's widgets visibly update on your canvas after the run. It also returns float("NaN") from IS_CHANGED, so it never gets cached itself. This is real plumbing, not a frontend trick.

    When it writes, it checks each value against the target's actual input spec. Linked inputs are never overwritten (a value driven by a wire gets skipped, with a note). INTs, FLOATs and BOOLEANs are coerced to the target's types, and values that aren't in a combo dropdown are skipped rather than crash. If a preset value doesn't apply, you get a reason, not silence.

    The inputs that matter

    Only one input is required:

    • node_identifier - the numeric ID or title of the target node to update. Copy the ID from the node's context menu or match its title exactly.

    Then three optional ones:

    • preset_values - the JSON object {widget_name: value} to write. Wire this to a Preset Manager's selected_values output; leave it empty and nothing applies.
    • only_widgets - a comma-separated whitelist of widget names (wildcards */? and substrings work). Handy when several Apply nodes fan out from one Preset Manager to different targets.
    • aliases - source=target renames, e.g. seed=seed_value, so a preset scanned from one node can feed a differently-named widget on another.

    Outputs: applied_values (JSON of what was actually written), applied (boolean), and notes - a string that tells you why something was skipped. When things don't work, read the notes first. There's also a compact mode (double-click) where the footer takes over the node body.

    Where you'd actually use it

    Pair it with Preset Manager, feed a reference_phrase like a prompt, and let keywords select whole bundles - a "portrait" tag flips CFG, sampler and steps on a distant KSampler in one shot. Or use it purely mechanically: one Apply node per target, fanned out from a single Manager, so a dropdown in one place reshapes the whole graph. It's the AUN ecosystem's answer to the "workflow as a reusable thing" problem, in the same spirit as the utility packs the author credits (rgthree, WAS, Impact Pack).

    Installation and gotchas

    Install the whole AUN pack - you can't get this node alone:

    cd ComfyUI/custom_nodes
    git clone https://github.com/loz2754/AUN-ComfyUI-Nodes
    

    Then restart ComfyUI. Easier: ComfyUI-Manager, search "AUN ComfyUI Nodes". The pack's requirements.txt declares piexif, opencv-python-headless, imageio-ffmpeg and requests; Manager installs them automatically, and if you cloned manually and hit ModuleNotFoundError: piexif or cv2, run:

    pip install -r custom_nodes/AUN-ComfyUI-Nodes/requirements.txt
    

    Biggest traps in practice: forgetting to connect preset_values at all (the footer will tell you), and expecting a linked input to be overwritten - it never is. And node_identifier matching is exact, so if the target's title changes, the apply silently fails with "target not found". That's what the notes output exists for.

    CategoryAUN Nodes/Utility

    Inputs (4)

    NameTypeDefaultDescription
    node_identifierSTRINGNumeric ID or Title of the node to update.
    preset_valuesoptSTRINGJSON object {widget_name: value} to write into the target's inputs. Optional — when left empty/unconnected, nothing is applied and the footer explains why.
    only_widgetsoptSTRINGOptional filter: comma-separated widget names to apply (everything else is ignored). Supports wildcards (*, ?) and substrings. Leave empty to apply all values.
    aliasesoptSTRINGOptional renames: comma-separated source=target pairs (e.g. 'seed=seed_value, steps=steps') applied before filtering, so a preset value scanned from one node can feed a differently-named widget on the target.

    Outputs (3)

    NameTypeDescription
    applied_valuesSTRING
    appliedBOOLEAN
    notesSTRING