ComfyUI Node Runs on cloud

AnyToAny

A Python eval in your graph — powerful, and the pack will warn you about it

By bmad4ever·Created 3 years ago·Updated 9 months ago· 70
AnyToAny
  • v
  • *
  • *
  • *
  • *
  • *
  • *
  • *
  • *
  • *
  • *
  • *
  • *
  • *
  • *
  • *
  • *
function

AnyToAny is the node that does whatever you tell it to. You feed it any value and a snippet of Python, it evaluates the snippet against that value, and returns the result - up to sixteen outputs, each one a slot for whatever the expression produced. It's the "I need a math or formatting operation that no dedicated node exists for, and I'd rather not write a custom node" escape hatch.

Here's the thing you have to respect before you use it: this node evaluates arbitrary code. The pack's own README flags it with the ⚠️ "potentially dangerous" icon, and the pack deliberately paints these nodes white in the UI so you notice them. The author uses simpleeval - a sandboxed, time-limited eval (120-second timeout, math available as m, compound types like lists allowed) - which is genuinely safer than a raw eval, but it's not a security boundary. Run this node only on workflows you wrote or fully trust, and never paste an expression you don't understand from a stranger.

How it works

  • v - the input value, of any type. Inside your expression, it's referenced as v.
  • function - a multiline text field with your Python expression. v * 2, [x for x in v if x > 3], m.sqrt(v) - anything single-expression-shaped.

The return value is unpacked across the node's outputs: a scalar lands in the first output, a list or tuple spreads its elements across the sixteen slots. That's why there are so many - it's a fan-out for list-producing expressions.

Honest use cases: one-off math, unit conversions, reshaping a list the pack's own list nodes can't quite handle, computing a value from several inputs before feeding a sampler. It's genuinely handy. But every time I use it, I read the expression twice and remember who wrote the workflow.

Install

Part of bmad4ever/comfyui_bmad_nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_bmad_nodes
cd comfyui_bmad_nodes
pip install -r requirements.txt

Restart, or ComfyUI Manager → search comfyui_bmad_nodes. Note simpleeval is a real dependency here (it's in requirements.txt along with opencv-python~=4.8.1.78, scikit-image, and gray2color) - if the node errors on import, that's the one to check. No models.

Gotchas

Expression must be a single expression, not statements - if blocks and print() calls will fail; use a conditional expression (x if cond else y) instead. If your expression returns nothing or the wrong shape, the sixteen-output fan-out makes the failure quiet: you'll get None in an output and a downstream type error that's hard to trace. And the big one: this node's sandbox is a convenience, not a promise. Treat it as the ⚠️ the author does.

CategoryBmad/⚠️⚠️⚠️

Inputs (2)

NameTypeDefaultDescription
v*
functionSTRING

Outputs (16)

NameTypeDescription
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**