ComfyUI Node

Invert Color

The complementary color, with no color-wheel app required

By akierson·Created 2 years ago·Updated 2 years ago· 2
Invert Color
  • color
  • color

Invert Color takes one COLOR and hands back its exact opposite - the complementary color. Feed it #ff0000 (red) and you get #00ffff (cyan). It's the same thing a color-wheel app does, except it lives in your graph and takes a COLOR input, so it plays nice with every other node in this pack.

Why would you want an inverted color mid-workflow? A few places. You've got a brand color and want the complementary accent for a two-tone look. You're building a check on contrast - text color vs. background - and want to know what the "opposite" of a given fill is. Or you're chaining two of them to verify a value round-trips (invert twice and you're back where you started, which is a handy sanity check when you're wiring up a new workflow). It's also the kind of node that's just fun to play with: pick a color, get its twin, adjust, done.

The mechanism is a neat bit of string math: each hex digit is mapped to its 15's complement - 0 becomes f, f becomes 0, 3 becomes c, and so on. Per channel that's exactly 255 − value, which is the correct definition of a complementary color. #336699 becomes #cc9966. Because it works digit-by-digit on the hex string, it's fast and has zero dependencies beyond the value it's handed.

Inputs: color (COLOR) - the swatch, as always. Outputs: color (COLOR) - the inverted value, ready to wire into anything that takes a color, including right back into itself.

Install. Standard for this pack. ComfyUI Manager: search "comfyui-colornodes" → install → restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/akierson/comfyui-colornodes

Restart ComfyUI. No pip dependencies beyond what ComfyUI already bundles and no model files, so this installs clean even on a box where dependency hell is a lifestyle.

Troubleshooting. The one assumption to keep in mind: it expects a clean hex color. The node lowercases whatever it's given, and a normal 6-digit hex is perfectly safe. If you somehow feed it a malformed value - a named color like "red", stray characters - you get garbage out, because the digit-table doesn't know what to do with letters past f. In practice you'll be feeding it from a Color Picker swatch, which always produces valid hex, so you probably won't hit this. Also worth knowing: it operates on the 8-bit hex, not on perceived brightness, so the "inverse" of a mid-gray is a mid-gray - the result isn't always a high-contrast pair. For that you'd want a luma-based approach, but for a true complement this is exactly right.

Small node, one job, no surprises. That's the whole pitch.

Categoryutils/color

Inputs (1)

NameTypeDefaultDescription
colorCOLOR

Outputs (1)

NameTypeDescription
colorCOLOR