Nodes/Pixel Palette Art/Color to formatted string
ComfyUI Node

Color to formatted string

Hex, CSS, GIMP or Amiga from one dropdown

By ranska·Created about a year ago·Updated 7 months ago· 1
Color to formatted string
  • color
  • formatted_color
format_typehex
alpha_value1.00
alpha_int255
css_var_namecolor
gimp_index-1

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#FF8000
  • hex_alpha#FF8000FF (takes alpha_int, 0–255)
  • rgb / rgbargb(255, 128, 0) / rgba(...)
  • tuple / tuple_alpha(255, 128, 0)
  • hslhsl(30, 100%, 50%)
  • css--color: #FF8000; using css_var_name (no leading -- needed)
  • gimp → a single GIMP palette line like 255 128 0 Orange, with gimp_index used 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) and alpha_int (0–255) - for the alpha variants. Yes, both exist, because rgba wants a float and hex-alpha wants an int.
  • css_var_name - for css.
  • gimp_index - for gimp.

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.

Categorypixel_art/output

Inputs (6)

NameTypeDefaultDescription
colorPIXEL_COLOR
format_typeCOMBOhex9 options: hex, hex_alpha, rgb, rgba, tuple, tuple_alpha, +3
alpha_valueoptFLOAT1.000–1Valeur alpha pour les formats supportés
alpha_intoptINT2550–255Valeur alpha entière (0-255)
css_var_nameoptSTRINGcolorNom de la variable CSS (sans --)
gimp_indexoptINT-1-1–999Index pour format GIMP (-1 = auto)

Outputs (1)

NameTypeDescription
formatted_colorSTRING