Version: 1.1.1 License: GPL-3.0
A general-purpose calculation node that executes user-written Python code and returns multiple text and numeric outputs based on the inputs.
This custom node accepts numbers (int/float) and text (string) as inputs, runs calculations and logical operations internally, and returns multiple values through separate output ports. It consolidates workflows that previously required combining several basic nodes into a single node.
- Navigate to the
ComfyUI/custom_nodes/directory. - Clone this repository:
git clone https://github.com/kantan-kanto/ComfyUI-ScriptFlow
- Restart ComfyUI.
- Multiple inputs: freely combine numeric and text inputs.
- Calculations and logic: supports arithmetic, comparison, and simple conditional branching.
- Multiple outputs: pass results to downstream nodes via separate output ports.
- Safer execution: restricted environment (no file/OS access).
- In Wan2.2 I2V workflows, automatically select a recommended resolution (512×384 or 384×512) based on whether the input image is portrait or landscape.
- Batch-generate file names (e.g., local LLM prompt history, output logs).
- Apply conditional logic to control workflow behavior (e.g., switch parameters or routes based on inputs).
- Parse and transform LLM outputs into structured values for downstream nodes. Dynamically generate numeric parameters (e.g., seeds, thresholds, scaling values) using custom calculations.
Category: utils
Inputs (optional, connectable):
in_text_1(accepts any input; validated asstrat runtime)in_text_2(accepts any input; validated asstrat runtime)in_text_3(accepts any input; validated asstrat runtime)in_value_1(accepts any input; validated asintorfloatat runtime)in_value_2(accepts any input; validated asintorfloatat runtime)in_value_3(accepts any input; validated asintorfloatat runtime)code(multiline string)
Outputs:
out_text_1(STRING)out_text_2(STRING)out_text_3(STRING)out_value_1(INT)out_value_2(INT)out_value_3(INT)
Notes on numeric outputs:
- Outputs are
INT. - If you need
FLOATvalues from integer inputs, use thecentinode. - If a value is a float, the fractional part is truncated on output.
- If you prefer rounding or ceiling, handle it in the script (e.g.,
round(...),math.ceil(...)).
Use the following variables inside code:
- Inputs:
it1,it2,it3,iv1,iv2,iv3 - Outputs:
ot1,ot2,ot3,ov1,ov2,ov3
Unassigned outputs default to None.
# Example: keep landscape at 512x384, portrait at 384x512
# Connect GetImageSize width/height to in_value_1/in_value_2
# iv1: image width, iv2: image height
w, h = iv1, iv2
ov1, ov2 = (512, 384) if w >= h else (384, 512)Category: utils
Inputs (optional, connectable):
int_1(INT)int_2(INT)int_3(INT)
Outputs:
float_1(FLOAT) =int_1 / 100float_2(FLOAT) =int_2 / 100float_3(FLOAT) =int_3 / 100
Notes:
- If
int_nis not connected, the correspondingfloat_noutput isNone. - The node is intentionally minimal and connector-only.
The script is executed using:
exec(code, globals_dict, locals_dict)len,min,max,sum,abs,roundint,float,str,boolsorted,reversedenumerate,range,zip,map,filterany,all,pow,divmodlist,dict,tuple
randomdatetimemath
importstatements- file access (
open, etc.) - OS operations (
os,sys) - re-running
eval/exec - blocked syntax in safe mode:
Import,ImportFrom,Global,Nonlocal,ClassDef,Try,With - blocked calls in safe mode:
__import__,eval,exec,compile,open,input,globals,locals,vars,getattr,setattr,delattr
- Using
randomordatetimemakes outputs non-deterministic. - Type mismatches raise an error and stop execution.
- Safe mode validates AST before execution and stops scripts that exceed the timeout (
1.5sby default). - Use only trusted scripts/workflows. Do not run untrusted code from unknown sources.
Demonstrates running the sample workflow with a landscape image and a portrait image.
examples/
├─ example_workflow.json
This project is licensed under the GNU General Public License v3.0.
Copyright (C) 2026 kantan-kanto
GitHub: https://github.com/kantan-kanto
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
- Issues: Report bugs or request features via GitHub Issues
- Examples: Check examples/ for workflow templates
- Added safe-mode AST validation before script execution.
- Blocked unsafe syntax (
Import,ImportFrom,Global,Nonlocal,ClassDef,Try,With,AsyncWith). - Blocked unsafe calls (
__import__,eval,exec,compile,open,input,globals,locals,vars,getattr,setattr,delattr). - Added execution timeout guard (
1.5sdefault) to stop runaway scripts. - Updated security notes for trusted-workflow usage.
Added centi node (utils).
- Minimal connector-only utility node.
- Three optional integer inputs:
int_1,int_2,int_3. - Three float outputs:
float_1,float_2,float_3. - Each connected input is converted by
int_n / 100; unconnected inputs returnNone.
- Improved documentation and project metadata.
- Initial release
