Nodes/ComfyUI-0246/Script Node
ComfyUI Node

Script Node

Wrap any ComfyUI node and run it inside a Script

By Trung0246·Created 3 years ago·Updated about a year ago· 137
Script Node
  • pipe_in
  • pipe_out
  • script_pin_data
  • script_exec_data
  • script_res_data
script_node
script_pin_order
script_pin_mode
script_res_order
script_res_mode
script_ignore_regex(?P<_>^$)

Script Node is the "pick any node" trick of the ComfyUI-0246 pack. It puts a dropdown in front of you with every node class currently loaded in your ComfyUI - the schema lists 285 choices, from KSampler and CheckpointLoaderSimple through CLIPTextEncode, VAEDecode, EmptyLatentImage, all the way down the list. You pick one, and this node parameterizes it for the pack's control-flow system. Instead of drawing a KSampler on the canvas and wiring it normally, you declare "I want a KSampler here, but I want its inputs fed from a pipe, run on demand, and its outputs re-packed back into the pipe."

Why would you bother? Because this is the core of the pack's "execute anything" trio (Script Node, Script Rule, Script). In a normal ComfyUI graph, a node runs exactly when its inputs are ready, once per queue. With these nodes you can run a node conditionally, loop it, or sweep a batch through it - things vanilla ComfyUI can't express without making the whole node list your input. If you just want one-off batch generation, skip it; if you're already neck-deep in Loop workflows, this is how you get a sampler inside the loop instead of outside it.

How it works

Script Node doesn't execute your chosen node itself. It introspects the class you picked - reads its INPUT_TYPES and RETURN_TYPES from ComfyUI's own node registry - and emits three SCRIPT_DATA packets that a 0246.Script node collects and orchestrates:

  • pin - how to unpack your Highway or Junction pipe into the target node's inputs
  • exec - the actual function that instantiates the target class and calls its execute method
  • res - how to re-pack the target's outputs back into a Highway or Junction pipe

That's why this node's outputs are script_pin_data, script_exec_data, and script_res_data, plus a pipe_out that just passes your pipe through.

The inputs that matter

A beginner really sets three:

  • script_node - the dropdown of 285 node classes. This is the whole point.
  • script_pin_mode - where the target's inputs come from: pin_highway (a named-lane Highway pipe) or pin_junction (a sequential Junction pipe). pin_direct exists in the enum but is not implemented - pick it and you get an error.
  • script_res_mode - how the target's outputs go back out: res_junction packs them into a Junction pipe, res_highway_batch into a Highway pipe whose lanes hold batches.

script_pin_order and script_res_order set execution order when you have several script nodes feeding one Script (sorted with natsort, same as the rest of the pack). script_ignore_regex lets you skip specific pins; the default regex only matches an empty string, so nothing gets ignored unless you change it.

How to install it

ComfyUI Manager is easiest - search "ComfyUI-0246" (or "0246") in Install Custom Nodes. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Trung0246/ComfyUI-0246

then restart ComfyUI. The pack's dependencies (wrapt, natsort, wat-inspector) install from its requirements.txt; there are no model downloads - every node in it is pure graph logic.

Common issues & troubleshooting

"pin_direct is not supported yet." That's a plain message from the source, not a misconfiguration - stick with pin_highway or pin_junction.

"Node class ... does not have any required input." Script Node refuses to wrap a node with no required inputs, and likewise one with no outputs. Pick a different target from the dropdown.

The dropdown looks different than a tutorial's. It lists what your install has - install more packs and more choices appear. That's also the honest warning about this whole pack: it's a single-author utility pack, dormant since early 2025, and it depends on internals (node registry introspection, custom execution) that ComfyUI's frontend rewrites have been known to break. It's brilliant when it works, but treat workflows built on it as a commitment. Save a plain workflow alongside your fancy one.

Category0246

Inputs (7)

NameTypeDefaultDescription
script_nodeCOMBO285 options: KSampler, CheckpointLoaderSimple, CLIPTextEncode, CLIPSetLastLayer, VAEDecode, VAEEncode, +279
script_pin_orderSTRING
script_pin_modeCOMBO3 options: pin_highway, pin_junction, pin_direct
script_res_orderSTRING
script_res_modeCOMBO2 options: res_junction, res_highway_batch
script_ignore_regexSTRING(?P<_>^$)
pipe_inopt*

Outputs (4)

NameTypeDescription
pipe_out*
script_pin_dataSCRIPT_DATA
script_exec_dataSCRIPT_DATA
script_res_dataSCRIPT_DATA