Color to formatted string
Hex, CSS, GIMP or Amiga from one dropdown
- color
- formatted_color
Color to formatted string is the node you reach for the moment you want a color out of ComfyUI - as text you can paste somewhere real. Feed it a single PIXEL_COLOR and it hands you back a STRING in whatever format you pick: #ff8000, rgb(255, 128, 0), hsl(30, 100%, 50%), a CSS custom property, a GIMP palette line, or even a raw Python tuple. It's the little brother of Palette Formatter, which does the same job for whole palettes; use this one when you're working with one color at a time.
This is a genuinely handy glue node. ComfyUI's native text output is fine for prompts, but it doesn't speak color formats. If you're generating a color, deciding you like it, and then pasting it into a CSS file, an Aseprite palette, or a GIMP .gpl, this node is the bridge - you format once and copy from the STRING output.
How it works
The node delegates to the PixelColor.exporter, which produces the string from the color's RGB values. The format list is where the personality shows:
hex→#FF8000hex_alpha→#FF8000FF(takesalpha_int, 0–255)rgb/rgba→rgb(255, 128, 0)/rgba(...)tuple/tuple_alpha→(255, 128, 0)hsl→hsl(30, 100%, 50%)css→--color: #FF8000;usingcss_var_name(no leading--needed)gimp→ a single GIMP palette line like255 128 0 Orange, withgimp_indexused if you set it (default -1 = auto)
The GIMP and CSS formats are the two I'd actually reach for. The Amiga-era crowd gets a treat too: the sibling Palette Formatter quantizes to 4-bit 12-color retro values, which is a surprisingly thoughtful touch for a pack about pixel art.
Inputs and outputs
The one required input you'll always wire is color (PIXEL_COLOR). format_type is a dropdown defaulting to hex. The optional inputs only matter for specific formats:
alpha_value(0.0–1.0) andalpha_int(0–255) - for the alpha variants. Yes, both exist, because rgba wants a float and hex-alpha wants an int.css_var_name- forcss.gimp_index- forgimp.
Output is a single formatted_color STRING, ready to pipe into a Show Text node or whatever text sink you use.
Installing
This is one of the sixteen nodes in the Pixel Palette Art pack. ComfyUI Manager → search "Pixel Palette Art", or:
cd ComfyUI/custom_nodes
git clone https://github.com/ranska/pixel_palette_art.git
Restart ComfyUI. The node lives under pixel_art/output. Dependencies: just Pillow, which you already have - no downloads, no models.
Common issues
The usual failure is feeding it something that isn't a PIXEL_COLOR. You can't type a hex string in - you have to build a color with Create Color From RGB (or Mix Colors, etc.) first. If the input wire is red, that's why. Out of the box the output is invisible too: STRING outputs don't render on the canvas, so pair it with a text-display node or you'll be staring at nothing wondering if it ran.
One quirk to know: gimp with default settings produces a one-line entry, not a full .gpl file - if you need a complete GIMP palette, use Palette Formatter with the gimp format instead.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| color | PIXEL_COLOR | — | |
| format_type | COMBO | hex | 9 options: hex, hex_alpha, rgb, rgba, tuple, tuple_alpha, +3 |
| alpha_valueopt | FLOAT | 1.000–1 | Valeur alpha pour les formats supportés |
| alpha_intopt | INT | 2550–255 | Valeur alpha entière (0-255) |
| css_var_nameopt | STRING | color | Nom de la variable CSS (sans --) |
| gimp_indexopt | INT | -1-1–999 | Index pour format GIMP (-1 = auto) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| formatted_color | STRING | — |