Nodes/Pixel Grid Helpers/Pixel Grid: Create Solid Color Image
ComfyUI Node

Pixel Grid: Create Solid Color Image

This Node Makes a Colored Rectangle — That's the Whole Job, and That's Why You Want It

By molbal·Created 11 months ago·Updated 27 days ago· 9
Pixel Grid: Create Solid Color Image
    • image
    ◄width512►
    ◄height512►
    ◄hex_code#FF0000►

    Sooner or later you need a frame that is one flat color. A backdrop to drop a cutout onto, a color card to eyeball a render against, a base layer for a composite, a single pixel of an exact hex you want to reuse somewhere else. And ComfyUI, which ships hundreds of nodes, makes this weirdly awkward: the obvious candidate, Empty Latent Image, gives you a latent - something you sample from, not an image you can see or composite. There's a core EmptyImage node that does roughly the same job, but if you already live in this pack, "Pixel Grid: Create Solid Color Image" is the three-box version: type a size, type a hex, get an IMAGE.

    It's the dumbest node in the pack by design. The whole pack is a deterministic post-process toolkit for pixel art - grid recovery, palette reduction, palette enforcement - and that layer is built on the idea that you reach for a cheap, instant, deterministic primitive before you throw another diffusion pass at a problem. This node is the floor of that idea: it doesn't touch pixels, it manufactures them.

    How it actually works

    The source is about ten lines, and reading it saves you guessing.

    It takes your hex_code, strips whitespace, and full-matches it against #?([0-9a-fA-F]{3}|[0-9a-fA-F]{6}) - so a leading # is optional, and 3- or 6-digit hex both work. Three-digit shorthand gets expanded by doubling each nibble, so f0A becomes FF00AA. Then it builds a float32 tensor with the RGB values divided by 255, shaped (1, height, width, 3), and expands that single pixel into the full frame.

    That shape matters more than it looks. It's the exact layout LoadImage produces - batch-first, height-width-channels, values in 0–1 - so anything downstream that accepts an IMAGE will accept this without complaint. The batch dimension is hard-coded to 1, which is worth knowing before you assume otherwise.

    The three inputs and the one output

    Everything here is required; there are no hidden optional knobs.

    • width / height - INT, 1 to 8192, default 512×512. Match these to whatever you're compositing onto, or to your target output size. A 1×1 is legal and genuinely useful if you just want a single swatch of a color.
    • hex_code - STRING, default #FF0000. Three or six hex digits, # optional, case-insensitive, surrounding whitespace ignored.

    The output is a single IMAGE called image. Because the node isn't an output node, nothing renders on its own - wire it into Preview Image or Save Image to actually see it, or feed it into a composite/blend/mask node as the base layer.

    One fun bit of pack synergy: run this into Pixel Grid: Analyze Palette and you get your hex back out as a hex_palette string, which then feeds Pixel Grid: HEX to Color Names if you want "Red" instead of #FF0000. It's a slightly silly round trip, but it's a fast way to check what a color actually is.

    Installing it

    Standard pack install - nothing special for this node.

    ComfyUI Manager: open Manager, search for "Pixel Grid Helpers", install, restart.

    Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/molbal/ComfyUI-PixelGridHelpers.git
    

    Or via the Comfy CLI from your ComfyUI root:

    comfy node install comfyui-pixelgrid-helpers
    

    Restart ComfyUI and refresh the browser. The nodes land under the Pixel Grid Helpers category.

    Good news on dependencies: there are none. The pack's pyproject.toml lists dependencies = [] and there's no requirements.txt, so you're not pulling in torch add-ons, Kornia, or a model download to make a colored rectangle. It runs on the standard ComfyUI environment.

    Where people get burned

    "Invalid HEX color" and the node refuses to run. The regex is strict on purpose. Named colors (red), 8-digit hex with alpha (#FF000080), 0x prefixes, and 4- or 5-digit strings all raise ValueError. Stick to 3 or 6 digits and you're fine - #FF0000, FF0000, and F00 are all valid.

    Wiring it into a sampler. It outputs an IMAGE, not a LATENT. If you wanted a solid-color generation, that's Empty Latent Image feeding the sampler; this node is for pixel work, compositing, and backgrounds.

    Expecting a batch. The output is always a batch of one, because the source hard-codes the leading dimension to 1. Need eight copies? Repeat the batch downstream rather than re-running the node - it's cheaper and keeps the color identical.

    Assuming it saves something. It doesn't. No output node behavior, no file written. Add a Save Image or you'll stare at a graph that appears to do nothing.

    CategoryPixel Grid Helpers

    Inputs (3)

    NameTypeDefaultDescription
    widthINT5121–8192—
    heightINT5121–8192—
    hex_codeSTRING#FF0000—

    Outputs (1)

    NameTypeDescription
    imageIMAGE—