Nodes/ComfyUI-ZML-Image/ZML_整数布尔互转
ComfyUI Node

ZML_整数布尔互转

The converter with a quirk you should read before trusting it

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_整数布尔互转
    • 布尔值
    • 整数
    整数
    布尔值

    ZML_IntegerBooleanConverter (ZML_整数布尔互转, "integer-boolean interconvert") is the kind of node you install as pack filler and then discover has opinions. Most converters in ComfyUI are boring pass-throughs. This one has a quirk: its integer↔boolean mapping is even = True, odd = False, and on the way back True = 0, False = 1. If you assume the natural mapping (nonzero = True, 1 = True), you will wire this up backwards and spend twenty minutes chasing a bug that isn't a bug.

    It's from ComfyUI-ZML-Image, zml-w's 160+ node pack, added in the October 2025 update that also brought its sibling float and string converters. It lives in the pack's logic subcategory.

    How it works

    Two optional inputs, two outputs:

    • 整数 (INT) in → 布尔值 (BOOLEAN) out: the integer's parity decides - even numbers become True, odd become False. Not "nonzero," not ">= something." Parity.
    • 布尔值 (BOOLEAN) in → 整数 (INT) out: True becomes 0, False becomes 1.

    Both inputs are optional and it converts whichever side is connected. If you only wire an integer, you get its parity as a boolean; if you only wire a boolean, you get its integer twin. The reverse direction is there whenever the corresponding input is connected.

    This is genuinely strange - you'd expect 1↔True and 0↔False. The even/odd and inverted mapping is almost certainly a personal convenience the author built for their own logic chains (this is a "I made it for myself" pack, and the README says exactly that about its less-used nodes). It works; it just works on the author's terms.

    When you'd use it

    It's pure plumbing - the graph-as-program layer where a boolean gate needs to talk to an integer-based switcher or a counter, or an integer node needs to flip a boolean toggle. The pack is full of switches, logic nodes, and "equality comparison" nodes that emit integers, so a converter that turns one into the other is genuinely useful within this pack. Wire it between a ZML logic node's integer output and a boolean toggle, and it does its job.

    Installing it

    Pack install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/zml-w/ComfyUI-ZML-Image
    

    restart ComfyUI, or ComfyUI Manager → search "ComfyUI-ZML-Image". Pure Python, no models, no dependencies beyond core.

    The only trap

    The mapping. Internalize it before you wire it: even → True, True → 0. If that isn't what you want, and you just need a sane 1/0 ↔ true/false, the stock PrimitiveBoolean and integer nodes in core ComfyUI give you the boring, predictable version. This node is for when you're deep in ZML logic-land and you want the conversion the pack's own chains expect - just don't trust it by instinct.

    And one honest note: this is exactly the kind of node where the author's own disclaimer applies - "the nodes I use often are polished, the ones I don't may have bugs." It's a two-line converter; there's not much to break. But it's also the node you should test once in a scratch workflow before you build a logic chain on it.

    Categoryimage/ZML_图像/逻辑

    Inputs (2)

    NameTypeDefaultDescription
    整数optINT
    布尔值optBOOLEAN

    Outputs (2)

    NameTypeDescription
    布尔值BOOLEAN
    整数INT