Color Converter (Swwan)
One colour in, three formats out, no calculator
- 字符串
- 颜色控件
The plumbing node you didn't know you needed
Some nodes want 255, 255, 255. Others want #ffffff. Others want a colour socket they can wire from somewhere else. Color Converter is the adapter: you give it one colour value in whatever form you already have, and it gives you back a string in the format you picked plus a colour-picker socket you can plug into Swwan nodes.
If your only colour task is typing a hex into a hex field, you don't need this node. You need it the moment a colour has to be either (a) reformatted for a text field you can't retype every run, or (b) driven by a wire rather than a widget.
Fair warning on the labels: the inputs are Chinese, because this node came out of 孤海's Goohaitools pack. 色值 is "colour value", 转换后 is "convert to". The outputs are 字符串 (string) and 颜色控件 (colour control). Everything below is what actually happens in the code.
How it works
色值 is parsed by trying formats in order: #RGB or #RRGGBB with or without the hash, 255,255,255 or (255, 255, 255), HSL written as 200, 50%, 50%, and normalised floats like 1.0, 0.0, 0.5. It also normalises full-width Chinese punctuation to ASCII, which is a nice touch if you're pasting from a Chinese UI. Whatever it parses to lands in internal 0–1 RGB.
转换后 then decides the string format:
#HEX→#ff8800HEX→ff8800(no hash - this is the one for nodes that reject the#)RGB→255,136,0HSL→30,100%,50%
The second output, 颜色控件, is always #rrggbb regardless of that setting.
Inputs and outputs
Only two inputs, both required: the colour string and the target format. That's the whole node. The outputs are a STRING (for text widgets, filename patterns, prompts - anywhere a string can go) and a COLORCODE.
COLORCODE is the pack's own socket type, with its own frontend widget (web/js/swwan_color_widget.js) that pops a native browser colour picker. It is not a core ComfyUI type. So the useful wiring is: Color Converter → region_color/number_color on Image And Mask Preview, and other Swwan nodes that declare a COLORCODE input. Trying to wire it into a core colour widget or another pack's colour input won't connect - that's a type mismatch, not a bug. In that case use the 字符串 output instead.
Install
Part of the pack, nothing per-node:
cd ComfyUI/custom_nodes
git clone https://github.com/aining2022/ComfyUI_Swwan
cd ComfyUI_Swwan
python -m pip install -r requirements.txt
Or Manager, searching ComfyUI Swwan. Restart, refresh, search Swwan in the node menu. Zero models, zero extra dependencies - this node is pure string handling from the pack's own code.
Where it bites
Bad input fails silently to white. If the parse doesn't match any of the patterns, the node returns pure white with no warning at all. So when your label comes out white instead of hot pink, the bug is your string, not the node. The usual causes: a stray space inside the digits (255, 136, 0 is fine actually - that one's handled), a hex with alpha (#ff8800ff, not supported), or a named colour like orange, which is not accepted here even though plenty of other nodes accept names.
HSL output is a display string, not a colour. 30,100%,50% is exactly what you'd paste into a CSS-ish field, and exactly what a node expecting R,G,B integers will choke on. The percentage signs are deliberate; don't strip them expecting a numeric triple.
Rounding is truncating for RGB. Internal values are floats and RGB output does int(value * 255), so a value that should be 255 can come out 254. Irrelevant for eyeballing a colour, very relevant if you're comparing hex strings in a workflow test.
And a mild one: this is one of the pack's 21 "primary" entries, which means it's meant to be your go-to for colour conversion rather than one of the specialist tools buried under Swwan/Advanced/. It shows up in the node search as Color Converter (Swwan) - the (Swwan) suffix is how you tell the pack's nodes apart from identically named ones from other packs.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| 色值 | STRING | #FFFFFF | — |
| 转换后 | COMBO | #HEX | 4 options: #HEX, HEX, RGB, HSL |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| 字符串 | STRING | — |
| 颜色控件 | COLORCODE | — |