Nodes/ComfyUI-Light-Tool/Light-Tool: RGB to Hex
ComfyUI Node

Light-Tool: RGB to Hex

Three ints in, one #RRGGBB out — the color-converter you'll forget you have

By ihmily·Created 2 years ago·Updated 4 months ago· 20
Light-Tool: RGB to Hex
    • hex_color
    R255
    G0
    B0

    This is a two-line function wearing a node costume: give it R, G, and B integer values and it returns the matching hex color string like #FF0000. That's it. It's the kind of node you'd normally just compute in your head, until you're wiring a value from somewhere else in the graph and need it as a real string type that another node will accept.

    What you get

    Three integer inputs, each clamped to 0–255 (the R default is 255, G and B default to 0 - so leave them alone and you get pure red). The output is a single hex_color string in #RRGGBB format, uppercase, always with the leading #. If a value slips outside 0–255 the node raises an error rather than silently wrapping, which is the right behavior for something you'll wire into other tools.

    Why you'd actually use it

    The honest use case is plumbing. This pack's color tools are hex-first: Solid Color Background and the various background nodes take hex strings directly. If you're computing a color numerically somewhere upstream - say a node that outputs an RGB triple, or you want to derive one color from another with math - this is the bridge that turns ints into the hex string the next node wants. It also pairs naturally with the pack's own Hex2RGB for round-trips.

    Beyond that, it's a convenience for people who like their prompt-adjacent text strings as hex and their math as numbers. You won't build a workflow around this node, but when it's the missing adapter, it's the whole job.

    Installing it

    It ships in ComfyUI-Light-Tool by Hmily. Easiest: ComfyUI Manager → search "ComfyUI-Light-Tool" → Install → restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ihmily/ComfyUI-Light-Tool
    pip install -r requirements.txt
    # restart ComfyUI
    

    It's pure Python string formatting - no models, no dependencies beyond what the pack already installs, works offline.

    Where people get burned

    • Expecting lowercase or no #. The output is uppercase with a #. If whatever you're feeding is picky, most tools accept both, but it's worth knowing.
    • Forgetting the range check. It's strict about 0–255. If a node upstream hands it a float or a 0–1 value, you'll get an error or a wrong color - convert first.
    • It's not a hex picker. There's no color widget here, just math in and string out. If you want to choose a color visually, use a color-picker node and read its hex directly.

    Small node, small job, no surprises - which is exactly what you want from a utility that sits in the middle of your graph doing one boring thing.

    CategoryComfyUI-Light-Tool/image/Color

    Inputs (3)

    NameTypeDefaultDescription
    RINT2550–255
    GINT00–255
    BINT00–255

    Outputs (1)

    NameTypeDescription
    hex_colorSTRING