ComfyUI Node

Color to Hex

Get the literal #RRGGBB string out of a color

By akierson·Created 2 years ago·Updated 2 years ago· 2
Color to Hex
  • color
  • hex_string

The COLOR widget in comfyui-colornodes is great at being a color. Sometimes, though, you need the text - the actual #RRGGBB string - to hand to something that only speaks text. That's exactly what Color to Hex does: one COLOR in, one hex_string out.

Why would you want the literal string? A few real cases. You're building a prompt and want to say the exact color ("deep teal" gets you whatever the model guesses, #0a3d2f gets you a specific one). You have a text-overlay node that writes a hex code into the image itself. You want to log the exact brand color into image metadata or a spreadsheet. Or you're passing a color into some node that only accepts a plain STRING and couldn't care less about fancy widgets. This node is the bridge between the clickable color world and the text world.

The mechanism is almost embarrassingly simple: a COLOR value is stored as a hex string under the hood, so this node mostly just unwraps it and hands it to you. That's why it's reliable - there's no parsing, no rounding, no color-space conversion to get wrong. What you pick is what you get.

Inputs: color (COLOR). Click the swatch, choose, wire it up. Outputs: hex_string (STRING), the color as text with the leading # included.

Install. Same as the rest of the pack. ComfyUI Manager: search "comfyui-colornodes" and install, then restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/akierson/comfyui-colornodes

Restart ComfyUI. No pip dependencies beyond what ComfyUI already bundles, no model downloads. This whole pack is one of the rare "clone and go" installs - no dependency hell to fight.

Troubleshooting. The output includes the #, which some downstream text nodes dislike. If a node chokes on it, strip the first character before feeding it onward. And because a COLOR picked from the swatch is always a 6-digit hex, the string is predictable - no 3-digit shorthand surprises, no named colors. If you feed this node from a non-standard source and get something weird back, the problem is upstream, not here.

Honestly, if you only ever click colors and never need to read them, you can skip this node. But the moment a workflow asks for a color as text, it's the node you'll be glad exists.

Categoryutils/color

Inputs (1)

NameTypeDefaultDescription
colorCOLOR

Outputs (1)

NameTypeDescription
hex_stringSTRING