ComfyUI Node Runs on cloud

Hex to HSL

Turn a picked color into numbers WAS's other color nodes can use

By WASasquatch·Created 3 years ago·Updated about 16 hours ago· 1,840
Hex to HSL
    • hue
    • saturation
    • lightness
    • alpha
    • hsl
    hex_color#FF0000
    include_alphafalse

    Not documented by name in WAS's own README, but the job is exactly what it says on the tin: take a hex color code - the #FF6600-style string you'd copy out of a color picker, a brand kit, or a design tool - and convert it into HSL: hue, saturation, and lightness as separate numeric components.

    Why that conversion specifically matters comes down to what WAS's other color nodes actually want as input. The README documents Image Generate Gradient ("Generate a gradient map with desired stops and colors"), Image Gradient Map, and Image Rotate Hue, whose hue_shift parameter is explicitly described in terms of a 0.0-to-1.0 rotation around the color wheel - "a hue_shift of 0.0 would represent no change, and 1.0 would represent a full circle of the hue." That's HSL-space math. Hex is great for humans picking a color visually; HSL is what you actually need if you want to do math on a color - nudge its hue programmatically, generate a sequence of evenly-spaced tones, or interpolate smoothly between two colors without the weird jumps you get interpolating hex/RGB directly. Hex to HSL is the bridge between "the color I picked" and "the numbers WAS's gradient and hue tools want to work with."

    A concrete way this gets used: pull a hex value out of WAS's own Image Color Palette node (which extracts a palette from an image), convert it to HSL with this node, nudge the hue or lightness by some offset, and you've got a programmatically-derived variant of a color that was originally sampled from a real image - useful for building coordinated gradient stops or palette variations without eyeballing hex codes by hand.

    Input is a hex color string; output is the HSL breakdown - expect separate H, S, and L values (as FLOAT or INT depending on how the node's built) rather than a single combined string, since that's what downstream math nodes would actually need to consume.

    Installing it: ComfyUI Manager, search "WAS Node Suite," install, restart - the easy path. Manual install: cd ComfyUI/custom_nodes && git clone https://github.com/WASasquatch/was-node-suite-comfyui, then pip install -r requirements.txt (portable: python_embeded\python.exe -s -m pip install -r requirements.txt; manual/venv: activate the venv first), restart ComfyUI. No model, no unusual dependency - it's color-space arithmetic, nothing more.

    Where it bites: on its own, basically nowhere - there's no external service or model involved, just a formula. The one thing worth double-checking is the hex string format itself: make sure you're feeding it a properly formatted hex code (with or without the leading #, depending on what the node expects) rather than a named color or an RGB tuple, since a malformed string is the most likely reason a pure-formula node like this would produce garbage output. Beyond that, the standing caveat for the whole pack applies: WAS Node Suite has been unmaintained since December 2023 (its README says "Retired"), and the community's recurring complaint is the entire suite failing to import after a ComfyUI update - check your console for that before troubleshooting this node specifically.

    CategoryWAS Suite/Utilities

    Inputs (2)

    NameTypeDefaultDescription
    hex_colorSTRING#FF0000The colour to convert, written as six hex digits for red, green and blue, '#FF0000' is pure red, or as eight with a trailing pair for opacity. The leading '#' is optional.
    include_alphaoptBOOLEANfalseWhether to read the last two hex digits as opacity. Off, alpha is reported as 1.0 and the string comes out as 'hsl(...)'; on, and given an eight-digit colour, the string comes out as 'hsla(...)'.

    Outputs (5)

    NameTypeDescription
    hueINTPosition on the colour wheel in degrees, 0 to 360: 0 is red, 120 green, 240 blue. Grey and white have no hue and report 0.
    saturationINTHow strong the colour is, as a percentage: 0 is grey, 100 is fully saturated.
    lightnessINTHow light the colour is, as a percentage: 0 is black, 50 is the pure hue, 100 is white.
    alphaFLOATOpacity from 0.0 to 1.0, rounded to two places. 1.0 unless include_alpha is on and the colour carried eight hex digits.
    hslSTRINGThe same colour as a CSS string, e.g. 'hsl(0, 100%, 50%)', ready for HSL to Hex or any node that takes a colour string.