Hex to Color Name 🦬
Turn a hex palette into words your image model actually understands
- color_name
- hex
Image models are great at "tomato red, steel blue, lime green" and useless at "#FF6347, #4682B4, #32CD32". Hex to Color Name bridges that gap: feed it hex codes, get back human color names ready to drop into a prompt. It's the small node that makes a sampled color palette usable - which is why it lives in Sokes Nodes 🦬 alongside Random Hex Color and Hex Color Swatch, the pack's color trio.
How it works
Two paths, depending on whether your hex has an exact name:
- If the hex matches a named CSS3 color exactly (like
#FF0000→ red), it uses that name directly. - If not - the common case for arbitrary palettes - it converts your color to Lab color space and finds the nearest named color using CIEDE2000 (the modern perceptual color-difference metric). Nearest in Lab means nearest the way human eyes see it, not nearest in RGB distance, so
#FF6347resolves to "tomato" rather than some arbitrary RGB neighbor.
There's also a use_css_name toggle. Off (default) it maps the CSS names through a human_readable_map that turns stuff like "darkslategrey" into friendlier phrasing; on, you get the raw CSS3 names for when you need standards-exact wording.
It validates and normalizes as it goes: missing # gets added, 3-digit shorthand expands, everything comes out uppercase. Up to 10 colors per call.
Inputs: hex_color (comma-separated codes, multiline) and use_css_name. Outputs: color_name (the names, comma-joined) and hex (the normalized hex codes, comma-joined).
Install
Standard Sokes Nodes 🦬 install:
cd ComfyUI/custom_nodes
git clone https://github.com/m-sokes/ComfyUI-Sokes-Nodes.git
pip install -r requirements.txt
or ComfyUI Manager → search "ComfyUI Sokes Nodes" → Install, restart. This node is the reason webcolors and colormath are in the pack's requirements - they do the heavy color-math lifting.
The workflow it enables
This is where the pack's color story comes together: Random Hex Color generates a palette, Hex Color Swatch shows it to you, and this node translates it into prompt words. Chain them and you can run a loop that generates a color scheme and a matching prompt every iteration. Combined with a prompt like "a product shot with a {color_name} background," you get systematic brand-color exploration without manually translating a single hex.
Gotchas are minor: invalid hex codes are silently skipped (you'll get fewer names than you typed), and colors that are truly unlike anything in the CSS map return "Invalid" or "Unknown" rather than crashing. Names are approximations, not magic - CIEDE2000 is good, but #C0C0C0 will still call itself silver and you may disagree. For prompt-building purposes, that's more than close enough.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| hex_color | STRING | #FF6347, #4682B4, #32CD32 | — |
| use_css_nameopt | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| color_name | STRING | — |
| hex | STRING | — |