ComfyUI Node

Programming

The Programming node is a pocket Python

By IxMxAMAR·Created 5 months ago·Updated 9 days ago· 1
Programming
  • values
  • data
  • string
  • int
  • float
  • bool
  • list
  • dict
  • any
◄modeaes_decrypt►
◄theme(use pack default)►
◄text►
◄max_length80►
◄afalse►
◄bfalse►
◄places0►
◄value0.00►
◄lo0.00►
◄hi1.00►
◄t0.50►
◄seed-1►
◄pattern►
◄group0►
◄replacement►
◄max_splits0►
◄template►
◄vars_json{}►
◄sep►
◄data_json{}►
◄key►
◄default►
◄index0►
◄start0►
◄stop0►
◄reversefalse►
◄path►
◄default_on_miss►
◄end10►
◄step1►
◄expri<10►
◄max_iters1000►
◄conditionfalse►
◄when_true►
◄when_false►
◄op==►
◄c►
◄cases_json{"_": ""}►
◄expected_hex►
◄plaintext►
◄ciphertext_b64►

The Programming node is the heavyweight of Utility-MegaPack, and the reason most people install the pack at all. Its mode dropdown holds 61 operations: control flow (for/while/if/switch), data structures (dict, list, JSON Path extraction), text and parsing (regex, sandboxed Jinja, YAML), math and stats, logic and bitwise, crypto (SHA/HMAC/AES-GCM), and encoding (base64, URL, slug). If you've ever stared at a workflow and wished you could just write a line of Python, this is the node that gets you most of the way there without leaving the canvas.

It earns its place in real graphs, not just show-off ones. Compute a step count or CFG value with eval_expr instead of hardcoding it. Pull the seed out of a saved filename with regex_extract. Build a save path or a prompt with template_render. Merge two DICTs from earlier nodes with dict_merge. These are the glue operations that turn a one-off workflow into something you can hand to someone else without a lecture.

How it works

Same architecture as every node in the pack: the mode dropdown picks a registered operation, that operation declares its own inputs, and one process method dispatches. There are seven typed outputs - string, int, float, bool, list, dict, and a wildcard any - and only the ones the active mode fills are live; the rest pad to empty defaults. So for_loop lands in list, hashes land in string, compare and the boolean ops land in bool, and eval_expr spits into any so it can return whatever type your expression produces.

The two inputs that carry most of the weight are expr (the expression or while-loop condition) and the *_json family - vars_json for expression bindings, data_json for dict ops, cases_json for switch/case. All expressions run through simpleeval, not eval(): no imports, no attribute poking, and any __ substring is rejected outright. The Jinja template renderer runs inside a sandboxed environment too. That's not paranoia - this pack had a full security audit in v0.3.0 specifically to close escape hatches, and given how custom-node malware has spread via shared workflows, it's the right instinct.

Installing it

It's one node out of the pack, so install the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-Utility-MegaPack

Restart ComfyUI (or use ComfyUI Manager → search "Utility-MegaPack"). No model downloads. Dependencies are numpy, Pillow, requests, simpleeval, Jinja2, PyYAML, cryptography - simpleeval and Jinja2 are the ones this node actually leans on, and both are lightweight.

Where people get tripped up

The sandbox is the thing people fight first. eval_expr will cheerfully do 2 + 2, but it will refuse to import os or touch anything dunder-related, and that's a feature. The while_loop is hard-capped at 100,000 iterations, so if your expression never becomes false you get a bounded list, not a frozen machine. Regex modes use Python's re syntax - the same patterns you already know from everywhere else. And the crypto ops are the pack's own implementation (AES-GCM with HKDF-derived keys, constant-time HMAC compare), not a shell-out to a system tool, so they behave consistently everywhere. One aside: it's easy to forget which typed output an op uses, so glance at the node's socket names before wiring - that's the single most common "why is my node red?" moment with this one.

CategoryUtility-MegaPack

Inputs (43)

NameTypeDefaultDescription
modeCOMBOaes_decrypt61 options: aes_decrypt, aes_encrypt, base64_decode, base64_encode, bitwise_and, bitwise_or, +55
themeCOMBO(use pack default)17 options: (use pack default), (use ComfyUI default), cyberpunk, minimalist, glassmorphic, retro_terminal, +11
textoptSTRING—
max_lengthoptINT801–1024—
aoptBOOLEANfalse—
boptBOOLEANfalse—
placesoptINT0-64–64—
valueoptFLOAT0.00—
looptFLOAT0.00—
hioptFLOAT1.00—
toptFLOAT0.500–1—
valuesoptLIST—
seedoptINT-1-1–4294967295—
patternoptSTRING—
groupoptINT00–99—
replacementoptSTRING—
max_splitsoptINT00–1024—
templateoptSTRING—
vars_jsonoptSTRING{}—
sepoptSTRING—
data_jsonoptSTRING{}—
dataoptDICT[object Object]—
keyoptSTRING—
defaultoptSTRING—
indexoptINT0—
startoptINT0—
stopoptINT0—
reverseoptBOOLEANfalse—
pathoptSTRING—
default_on_missoptSTRING—
endoptINT10—
stepoptINT11–1000000—
exproptSTRINGi<10—
max_itersoptINT10001–100000—
conditionoptBOOLEANfalse—
when_trueoptSTRING—
when_falseoptSTRING—
opoptCOMBO==6 options: <, >, <=, >=, ==, !=
coptSTRING—
cases_jsonoptSTRING{"_": ""}—
expected_hexoptSTRING—
plaintextoptSTRING—
ciphertext_b64optSTRING—

Outputs (7)

NameTypeDescription
stringSTRING—
intINT—
floatFLOAT—
boolBOOLEAN—
listLIST—
dictDICT—
any*—