ComfyUI Node

IDE Node

Run your own Python or JavaScript right inside the node graph

By AlekPet·Created 3 years ago·Updated 6 days ago· 1,520
IDE Node
  • pycode
  • result
languagepython

Sooner or later every ComfyUI workflow hits a moment where you need one small, specific piece of logic that no existing node does - some string manipulation, a bit of math on a number coming out of another node, a quick conditional. Normally that means going and writing a whole custom node just to fill a five-line gap. IDENode is the escape hatch: a code editor built directly into the node itself, where you write actual Python (or JavaScript) and it runs inline, no separate node package required.

This is filed under "AlekPet Nodes/experiments" in the pack, and that label is honest - it's a genuinely different kind of tool from everything else in this pack, and it comes with a genuinely different kind of risk.

Why you'd reach for it

The case is glue code: you've got values flowing through your graph and you need to transform, combine, or branch on them in a way no existing node covers, and writing a proper custom node for a one-off transform is overkill. IDENode lets you write that logic directly, see it, edit it, and iterate on it live in the graph - closer to a scripting cell in a notebook than a typical ComfyUI node.

How it works

You pick a language (Python or JavaScript) and write code in the pycode field. Your code runs with access to whatever variables the node's inputs are wired to (the default template comments mention "Globals inputs variables: var1, var2, var3, user variables..."), and whatever you assign to result becomes the node's output. The default starter code is a small, harmless example: it grabs the current date/time and returns a greeting string, which is really just there to show you the shape of a working script - read/return, nothing fancier.

The inputs and outputs that matter

  • language (default python) - python or javascript. Determines what your code in pycode is interpreted as.
  • pycode (type PYCODE) - the actual code editor field. The node's own default content opens with a comment worth repeating verbatim, because it's the whole safety model for this node: "!!! Attention, do not insert unverified code !!!"
  • Output: result, typed * (any) - whatever your code assigns to the result variable, passed through as-is to whatever's wired downstream. Because the output type is untyped, ComfyUI won't stop you wiring it into something expecting a specific type (STRING, IMAGE, etc.) - that's on you to get right, since a type mismatch downstream will surface as a runtime error rather than something caught at graph-build time.

How to install it

Via ComfyUI Manager: search "ComfyUI Custom Nodes AlekPet" and install. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet

Restart ComfyUI. No model downloads, no extra dependencies beyond ComfyUI's own Python environment - your code runs in that same environment, which is exactly why the warning in the default code matters.

Common issues & troubleshooting

This node can run arbitrary code with the same permissions as ComfyUI itself. This is the one honest thing to say about IDENode before anything else: it is not sandboxed. Code in this node reads and writes to the filesystem, makes network calls, does anything your ComfyUI process itself is allowed to do - same as if you'd written a Python script and run it directly. Never paste in code from a workflow, JSON file, or someone else's shared graph that you haven't read and understood. ComfyUI's whole node ecosystem already runs with broad filesystem access by design (custom nodes are arbitrary Python), but IDENode is the one place that's handed to you directly, in the open, per-node - treat any pycode field you didn't write yourself with the same suspicion you'd give a downloaded .exe.

Your result output doesn't match what the next node expects. Because the output type is * (untyped), nothing checks this for you at graph-build time - a STRING-expecting node fed a number, or vice versa, will error at runtime rather than when you connect the wire. Double-check what you're assigning to result matches what's wired downstream.

Variables from wired inputs aren't showing up as expected. The default template's comment references "Globals inputs variables: var1, var2, var3" - the exact variable names and how many are available depend on how many input slots you've added to the node; if something's not resolving, check you're referencing the right variable name for the input slot you actually connected.

JavaScript mode behaves differently than you expect coming from the Python default. The starter template shipped with the node is Python-flavored; if you switch language to javascript, you're working in a different runtime with different syntax and different available globals - don't assume the Python example translates directly.

CategoryAlekPet Nodes/experiments

Inputs (2)

NameTypeDefaultDescription
languageCOMBOpython2 options: python, javascript
pycodePYCODE# !!! Attention, do not insert unverified code !!! # ---- Example code ---- # Globals inputs variables: var1, var2, var3, user variables ... from time import strftime def runCode(): nowDataTime = strftime("%Y-%m-%d %H:%M:%S") return f"Hello ComfyUI with us today {nowDataTime}!" result = runCode()

Outputs (1)

NameTypeDescription
result*