Nodes/comfyui-palette-toolkit/Hex Palette Builder
ComfyUI Node

Hex Palette Builder

Because your prompt cannot see #66788C

By CrimsonEarth·Created about a month ago·Updated 10 days ago· 0
Hex Palette Builder
    • palette_image
    • normalized_hex
    • palette_json
    hex_codes#1B2029 #66788C #E7DFC9 #A88443 #D5A33B #78A9BA
    width1024
    height256
    layouthorizontal
    gap0

    Put a hex code in a prompt and the model does one of two things: ignores it, or worse - writes it. There's a thread on r/comfyui where someone asked for a dress in zomp (#39a78e) and got a blue dress with the word ZOMP across it. Hex codes are tokens, not colors. If you want a specific color to actually exist in your output, it has to be pixels at some point in the graph.

    That's what this node is for. It takes a list of hex codes and turns it into a real RGB image - plus the same palette in two text forms you can wire into other nodes or save as metadata. It's the boring, load-bearing half of the Palette Toolkit, and it's the one you'll use as the palette's single source of truth.

    (The exception that proves the rule: Ideogram 4 was trained on structured JSON captions with hex palettes and bounding boxes, so hex conditioning genuinely works there. Everywhere else, you're talking to a text encoder that has never seen a # followed by six hex digits.)

    What it does

    You paste colors, it renders swatches. The canvas is filled with a dark gray (0.055, about #0E0E0E) and each color gets a cell, inset by gap pixels on every side.

    • horizontal - one column per color, full height. Good for a reference strip.
    • vertical - one row per color, full width. Good for a slim sidebar swatch you leave sitting next to your graph.
    • grid - columns are worked out from the canvas aspect ratio (ceil(sqrt(count × aspect))), so a near-square palette gets a near-square grid.

    The colors come out as exact 8-bit values. No interpolation, no gamma weirdness - a swatch of #D5A33B is #D5A33B in the tensor.

    The inputs that matter

    hex_codes is the whole point of the node. The parser accepts whitespace, commas, semicolons, pipes or newlines as separators, takes #RRGGBB, RRGGBB, 0xRRGGBB and #RGB shorthand, dedupes repeats, and caps out at 32 colors.

    width / height (64–8192, step 8) default to 1024×256 - a wide strip. Bump them if you're saving the swatch as a printable reference sheet.

    layout and gap are cosmetic, and gap behaves exactly like an inset on both sides of every cell. That has a real consequence: a big gap can eat your swatches entirely. At 1024 wide with 6 colors, each cell is ~170px; set gap to 128 and the cell's own edges cross, so those colors are skipped silently. There's no warning. Keep gap under roughly a quarter of a cell.

    The outputs

    palette_image is a genuine ComfyUI IMAGE - a true-color swatch with actual pixels in it. You can wire it into a style-reference path at low weight, but the README is upfront that model-specific conditioning bridges are out of scope, so expect to tune that yourself: a flat color field is not a photograph. Mostly it's the thing you feed to SaveImage so the palette sits on disk next to the results, or to PreviewImage while you iterate.

    normalized_hex is your palette rewritten as clean uppercase #RRGGBB, one per line. Right-click a node's hex_codes widget, choose Convert widget to input, and you can wire this straight into it - so the Hex Palette Builder becomes the one place you edit colors and everything downstream follows. That's the standard primitive-node move: one authoritative source, many consumers.

    palette_json is a compact JSON array - ["#1B2029","#66788C",…]. It's a plain STRING, so it's for API workflows, filename prefixes, or any node downstream that wants to parse JSON itself. Handy if you drive ComfyUI as an API and want the palette to appear in the job record.

    Installing it

    Manager, search Palette Toolkit, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/CrimsonEarth/ComfyUI-Palette-Toolkit
    # restart ComfyUI
    

    That's the whole install. No requirements.txt, no models, no pip step - it runs on ComfyUI's own PyTorch. Honestly, this is the lowest-risk install you'll do this month.

    Traps

    The parser errors are terse and easy to trigger. Invalid RGB hex color: '255' means you typed a decimal RGB triple - 255,0,0 is not hex. And a bare 255 is worse than an error: it's a legal three-digit hex code, so it silently becomes #225555. Labels break it too - red: #FF0000 won't parse. Clean tokens only, max 32 of them.

    Watch the size limits if you go big. A ComfyUI IMAGE is float32, so 8192×8192 is around 800 MB of tensor for what is, functionally, a color swatch. There's no reason to render a palette at 8K.

    And if the node doesn't appear in the menu after a restart, look for folder nesting (ComfyUI-Palette-Toolkit/ComfyUI-Palette-Toolkit) and check the startup log - the pack registers its nodes normally, so a missing node means an import failed, not that it's half-installed.

    Categoryimage/palette toolkit

    Inputs (5)

    NameTypeDefaultDescription
    hex_codesSTRING#1B2029 #66788C #E7DFC9 #A88443 #D5A33B #78A9BARGB colors separated by whitespace, commas, pipes, or newlines.
    widthINT102464–8192
    heightINT25664–8192
    layoutCOMBOhorizontal3 options: horizontal, vertical, grid
    gapINT00–128

    Outputs (3)

    NameTypeDescription
    palette_imageIMAGE
    normalized_hexSTRING
    palette_jsonSTRING