String To ColorCode
When ComfyUI Won't Let You Plug a Hex String Into a Color Picker
- color_code
You've hit this before: some node in your workflow spits out a hex color as plain text - an LLM generating a palette, a JSON parser, a node that computes a color - and the node you're feeding it into has a little color swatch input that just won't accept the wire. That swatch is a COLORCODE socket, and ComfyUI's type system treats it as a completely different type from STRING, so the connection silently refuses to form. String To ColorCode exists for exactly that one moment. It's a tiny type adapter: hex string in, COLORCODE out.
What it actually does
The whole node is one input and one output, and the work happens in the middle. Feed it any reasonable hex string and it comes out the other side normalized to the format the color-picker nodes expect.
The input is color_hex, a STRING. The output is color_code, typed COLORCODE. Under the hood it's just a string - COLORCODE is a label in ComfyUI's type system, not a special object - so the node is really a relabeler with a validator bolted on. The conversion logic is trivial and sits right there in the pack's single __init__.py:
00FF00→#00FF00(adds the#you forgot)#0F0→#00FF00(expands 3-digit shorthand)#00ff00→#00FF00(uppercases)
One thing the README undersells: the code also accepts 8-digit RGBA hex like #00FF00FF, so alpha-carrying colors pass through too. It strips surrounding whitespace, and if the value doesn't match at all it raises a clear error - "String To ColorCode expected a hex color like #00FF00, got: …" - which beats the silent nothing you get from an unconnectable socket.
The gotcha that trips people up
Because the input is declared with forceInput: True, you can't just double-click the node and type a color into a box. That field only exists as a socket - you have to wire something into it. For a bridge node that's the point, but it means a standalone test setup needs a string source: a Primitive node, a text output from any other node, or whatever's producing your hex in the first place.
The list/tuple handling is a quiet nicety worth knowing: if a list output lands on the input, it takes the first element rather than erroring out. Nothing to configure, but it means batchy workflows won't explode on you.
Install
This is the rare custom node that's genuinely painless, which is nice after the usual ComfyUI dependency gauntlet. It's pure Python using only the standard library - no requirements.txt, no model downloads, no torch, nothing to break your environment. Install via ComfyUI Manager (search ColorCode Bridge) or:
cd ComfyUI/custom_nodes
git clone https://github.com/Doki21yy/ComfyUI-ColorCode-Bridge
Restart ComfyUI. The node shows up under utils/color as "String To ColorCode". That's the entire setup - I've installed heavier browser extensions.
When to reach for it
Honestly? This is a niche utility for a niche problem, and 0 Google impressions tells you most people never hit it. But if you're building LLM-driven workflows where a model outputs a hex palette and you need it wired into a color-aware node, or you're scripting through the API and constructing workflows programmatically, the type mismatch is real and this is the cleanest fix. It's also just a good pattern to recognize: when ComfyUI refuses a connection, the answer is often a tiny adapter node like this rather than fighting the graph.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| color_hex | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| color_code | COLORCODE | — |