Nodes/fxai-toolkit/凤希AI - 字符串转数字
ComfyUI Node

凤希AI - 字符串转数字

The tiny node that unblocks a whole pipeline

By fxai666·Created 4 months ago·Updated 3 days ago· 35
凤希AI - 字符串转数字
    • 输出整数
    • 输出小数
    输入数字1

    FxAiStrToNumber ("凤希AI - 字符串转数字") takes a string and hands you both an INT and a FLOAT. One input, two outputs, zero cleverness. You'd think ComfyUI doesn't need this - and most of the time it doesn't, because the UI primitives already give you typed number widgets. The node earns its keep the moment a value arrives as text.

    When it actually matters

    In this pack specifically, numbers keep getting born as strings. A storyboard row you parsed out of JSON, a value pulled from an external file list, a directory path with an index appended, an API response you slurped into a text node - all of those are STRINGs by the time they hit the graph. But the loop controllers, the segment calculators, and every sampler on earth want INT or FLOAT sockets. Type mismatch means no wire. This node is the adapter.

    It's also handy when you're hand-typing numbers into a workflow you plan to share: a string widget is friendlier than a step-constrained spinner for someone who wants to paste a value in.

    How it works

    Dead simple: it tries int(输入数字) and float(输入数字) and returns both. The inputs:

    • 输入数字 - a STRING, default "1".

    The outputs:

    • 输出整数 - INT
    • 输出小数 - FLOAT

    Wire whichever one your downstream node wants.

    The gotcha nobody warns you about

    Read the source and you'll find the quiet catch: if int() or float() throws, the node doesn't error - it returns (0, 0.0). So a mistyped string, a number with thousands separators ("1,024"), or an empty field silently becomes zero.

    In a loop workflow that's brutal. Zero your 当前索引 or your frame count and you don't get a crash, you get a silent garbage run that you only notice after the render completes. Treat the (0, 0.0) fallback as the feature-was-really-a-footgun it is: keep your input clean, and if you ever see an unexpected 0 from this node, go read the string feeding it first.

    Installing it

    It's part of fxai-toolkit, so one install covers every 凤希AI node:

    cd ComfyUI/custom_nodes
    git clone https://github.com/fxai666/fxai-toolkit
    

    Restart ComfyUI after cloning (or install via ComfyUI Manager, searching "fxai-toolkit"). No model files, no extra dependencies worth worrying about - the pack auto-installs soundfile and psutil on load.

    This node has no settings worth fiddling, no version drama, and it can't be blamed for bad output. It's a three-line utility that saves you a custom Python node's worth of effort. Fine with the fallback, you'll never think about it again.

    Category凤希AI/工具

    Inputs (1)

    NameTypeDefaultDescription
    输入数字STRING1

    Outputs (2)

    NameTypeDescription
    输出整数INT
    输出小数FLOAT