Random Color Combination Generator
Generate harmonious random color combinations with background, foreground & accent colors. WCAG contrast check, multiple harmony modes, export palettes.
About
Selecting color combinations by intuition leads to accessibility failures and visual dissonance. A background-foreground pair that feels right on your monitor may produce a WCAG contrast ratio below 4.5:1, rendering text illegible for roughly 8% of male users with color vision deficiency. This tool generates mathematically derived palettes: it picks a random RGB background, computes its complementary inverse (Rfg = 255 − Rbg) for guaranteed contrast, then derives an accent by shifting the hue 30° in HSL space and scaling lightness through the golden ratio φ ≈ 1.618. Five harmony modes (complementary, analogous, triadic, split-complementary, tetradic) follow standard color theory geometry on the HSL wheel. Every generated palette is checked against WCAG 2.1 luminance formulas, and a color-blindness simulator applies Brettel-Viénot transformation matrices so you can verify perception under protanopia, deuteranopia, and tritanopia before committing to production CSS.
Formulas
The relative luminance L of a color determines its perceived brightness and is the basis for WCAG contrast computation. Each sRGB channel is linearized before weighting:
where each linearized channel Clin is computed from the sRGB value Csrgb ∈ [0,1]:
The contrast ratio between two luminances L1 (lighter) and L2 (darker):
Complementary foreground is computed by channel inversion:
Accent color uses the golden ratio φ ≈ 1.618 to shift lightness in HSL space, then rotates hue by 30°:
where L = relative luminance (WCAG), Csrgb = normalized sRGB channel [0,1], CR = contrast ratio, H = hue in degrees, φ = golden ratio.
Reference Data
| Harmony Mode | Hue Offset(s) | Use Case | Contrast Tendency |
|---|---|---|---|
| Complementary | 180° | High-impact hero sections, call-to-action buttons | High |
| Analogous | ±30° | Calm, cohesive branding, editorial layouts | Low |
| Triadic | ±120° | Vibrant illustrations, children’s products | Medium |
| Split-Complementary | 150° & 210° | Balanced contrast without tension | Medium-High |
| Tetradic (Rectangle) | 90°, 180°, 270° | Complex dashboards, data visualizations | Variable |
| WCAG 2.1 Contrast Thresholds | |||
| AA Normal Text | ≥ 4.5:1 | Minimum for body copy | |
| AA Large Text | ≥ 3.0:1 | ≥ 18pt or 14pt bold | |
| AAA Normal Text | ≥ 7.0:1 | Enhanced readability | |
| AAA Large Text | ≥ 4.5:1 | Enhanced for large text | |
| Color Vision Deficiency Prevalence | |||
| Protanopia (no red) | 1.3% of males | Red-green confusion | |
| Deuteranopia (no green) | 1.2% of males | Red-green confusion | |
| Tritanopia (no blue) | 0.01% | Blue-yellow confusion | |
| Protanomaly (weak red) | 1.3% of males | Reduced red sensitivity | |
| Deuteranomaly (weak green) | 5.0% of males | Most common deficiency | |
| Common Named Color Coordinates | |||
| Pure Red | rgb(255,0,0) | hsl(0,100%,50%) | #FF0000 |
| Pure Green | rgb(0,128,0) | hsl(120,100%,25%) | #008000 |
| Pure Blue | rgb(0,0,255) | hsl(240,100%,50%) | #0000FF |
| Coral | rgb(255,127,80) | hsl(16,100%,66%) | #FF7F50 |
| Teal | rgb(0,128,128) | hsl(180,100%,25%) | #008080 |
| Gold | rgb(255,215,0) | hsl(51,100%,50%) | #FFD700 |