Nodes/ComfyUI-mnemic-nodes/🎲 Random Color
ComfyUI Node

🎲 Random Color

A Random Colour With Hex and Channels Split Out

By MNeMoNiCuZΒ·Created 3 years agoΒ·Updated a day agoΒ· 105
🎲 Random Color
    • hex_color
    • red
    • green
    • blue
    β—„seed-1β–Ί

    🎲 Random Color rolls an RGB colour and hands it to you two ways: as a #RRGGBB string and as three 0–255 integers. It has no required inputs at all, which tells you what it is - a source node you drop in when something in the graph wants a colour and you'd rather not pick one.

    Be honest about its market: most ComfyUI nodes take colours as widgets you can't wire, so this isn't a node you'll use weekly. Where it does earn a slot is the pack's own 🎨 Colorful Starting Image, whose background_color input is a string that accepts hex codes and CSS colour names - that's a genuine pairing, and it's how you get abstract starters whose background varies with everything else in the batch. Beyond that, the channel outputs are for maths: mask tint levels, per-channel jitter on a grain or noise pass, a random fill in a procedural graphic.

    How it works

    With seed at its default -1, the three channels come from Python's unseeded RNG - a fresh draw whenever the node executes. Set a seed β‰₯ 0 and it builds a local random.Random(seed) instead, so the same seed gives the same colour: handy when you found a palette you like and want it back, or when you're reproducing a batch.

    One caching consequence worth knowing, since it applies to every random node in this pack: ComfyUI skips re-executing nodes whose inputs haven't changed. The pack's Random Seed node pins a time.time() fingerprint to force itself to run every time; the seeded random nodes like this one don't. If your -1 colour looks stuck, the cache is why - change something upstream, or set a seed and increment it.

    The hex output is normalised to uppercase two-digit channels (#FF5733), so you can concatenate it into a filename or a prompt without worrying about formatting.

    Inputs and outputs

    One optional input, seed. Outputs: hex_color (STRING), plus red, green, blue, each an INT 0–255.

    hex_color is the one you wire into string inputs - a colour field, a colour-matching prompt, a Save Text File. The integer channels go into maths nodes or anything with a numeric colour parameter; if a node wants a 0–1 float, you'll need a division in between, since this node doesn't offer one.

    Install

    ComfyUI Manager β†’ search "ComfyUI-mnemic-nodes" β†’ install β†’ restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MNeMoNiCuZ/ComfyUI-mnemic-nodes
    

    Nothing to download for this node; the pack's requirements.txt installs its larger dependency set (transformers, opencv-python, tiktoken, piexif, and so on) for other nodes. No API keys, no models.

    Common issues

    The colour never changes. Cache, or a fixed seed. See above.

    Muddy, grey-brown results. Uniform RGB over the full cube is mostly desaturated - that's just what the colour space looks like when you sample it uniformly. If you wanted vivid, this node doesn't do HSV or palette-constrained rolls; the pack's Colorful Starting Image has a color_palette and color_harmony setting for that job instead, and it's the better tool.

    Downstream node won't take the wire. It wants a colour widget, not a string. Only nodes with a string-typed colour input - like background_color on Colorful Starting Image - will accept hex_color.

    Category⚑ MNeMiC Nodes

    Inputs (1)

    NameTypeDefaultDescription
    seedoptINT-1-1–18446744073709550000Seed for random number generator. Use -1 for random seed (different each time), or set a specific value for reproducibility.

    Outputs (4)

    NameTypeDescription
    hex_colorSTRINGThe rolled colour as #RRGGBB.
    redINTRed channel of the rolled colour, 0-255.
    greenINTGreen channel of the rolled colour, 0-255.
    blueINTBlue channel of the rolled colour, 0-255.