Nodes/BV Node Pack/πŸŒ€ BV Hex Color β†’ Int
ComfyUI Node

πŸŒ€ BV Hex Color β†’ Int

The two-line node that turns '#ff8800' into a number some other node actually wants

By BlackVortexAIΒ·Created 8 months agoΒ·Updated a day agoΒ· 6
πŸŒ€ BV Hex Color β†’ Int
    • color
    β—„hex#ffffffβ–Ί

    BV Hex Color To Int converts a hex color string like #ff8800 into a single integer. That's it. It exists because a surprising number of ComfyUI nodes - color-tint things, background fillers, palette utilities - accept colors as plain ints (often the 0–0xFFFFFF range) rather than as #RRGGBB text, and typing 16744448 by hand is how you end up with colors you didn't want.

    This is a utility node, so let's be honest about its scope: it's not going to change how you work, it's going to remove one tiny recurring annoyance. If you've ever had to open a hex-to-dec converter just to feed a color into a node, this kills that tab. It's the kind of node you install once, forget about, and are quietly glad exists when you need it.

    How it works

    The mechanism is a single function with some forgiving input handling. You feed it the hex input (a string, default #ffffff) and it accepts any of these spellings:

    #ff8800
    0xff8800
    ff8800
    #f80        (3-digit shorthand, expanded to ff8800)
    

    The backend strips the # and 0x prefixes, expands 3-digit shorthand to 6 digits, and converts the result with int(s, 16). The output color is an INT in the 0–0xFFFFFF range. If the input isn't a valid hex color, it raises a ValueError with a message listing the accepted formats - so you get a named error rather than a garbage number silently flowing into your sampler.

    One input, one output, no hidden state, no models, no dependencies. That's the entire API surface.

    Where it fits

    Wire it wherever a node wants a color as an int. Common pairings: an image-tint or gradient node that takes an int color, a background-color input on a compositing node, or a palette node you're feeding from a config string. Because it's a pure conversion, you can also chain it behind a text-field or a dropdown - pick a color name in a combo, convert, feed the tint node. The color output is just an int, so it plays with any INT input you'd normally type a number into.

    Install & gotchas

    Same install as the whole pack: ComfyUI Manager β†’ search BV Node Pack, or

    cd ComfyUI/custom_nodes
    git clone https://github.com/BlackVortexAI/bv_nodepack.git
    

    then restart ComfyUI and hard-refresh the browser (Ctrl + F5). This node has no JS UI and no dependencies, so it's the easiest of the pack's nodes to get running - the hard refresh matters for the pack's other nodes, not really this one.

    The only failure mode worth knowing: invalid input throws rather than forgiving. A color like #gg8800 or a bare ff8800ff (8-digit with alpha) will error out. Paste a valid 3- or 6-digit hex and you can't go wrong. And note the README calls the input prompt in a few places - the actual registered input is hex, so that's what you'll see on the node.

    CategoryπŸŒ€ BV Node Pack/utils

    Inputs (1)

    NameTypeDefaultDescription
    hexSTRING#ffffffβ€”

    Outputs (1)

    NameTypeDescription
    colorINTβ€”