Free Online Color Generator
Generate random colors, create palettes, convert formats, and explore color schemes in HEX, RGB, and HSL.
Color Converter
------Color Schemes
Recent Colors
Key Features
Live Preview
See generated colors in real time with instant visual feedback.
Format Converter
Convert between HEX, RGB, and HSL formats instantly. Paste any color value.
Color Schemes
Explore complementary, analogous, triadic, and tetradic color harmonies mathematically derived.
Contrast Checker
WCAG 2.1 contrast ratios against white and black backgrounds for accessibility.
Understanding Color Generation: HSL, Color Difference, and Accessible Design
HSL Color Space: The Foundation of Programmatic Palette Generation
HSL (Hue, Saturation, Lightness) is the preferred color space for algorithmic palette generation because its three dimensions map intuitively to how humans perceive color. Hue is measured in degrees (0-360) around a color wheel: red at 0deg, yellow at 60deg, green at 120deg, cyan at 180deg, blue at 240deg, and magenta at 300deg. Saturation (0-100%) controls the intensity or purity of the color — 0% produces gray, while 100% is the pure hue. Lightness (0-100%) controls brightness: 0% is black regardless of hue, 50% is the purest form of the hue, and 100% is white. Unlike RGB, where adjusting a single value unpredictably shifts the color, HSL allows independent control of each dimension. To generate a harmonious palette, keep saturation and lightness constant while rotating the hue value. For example, a triadic palette divides the hue wheel into thirds (0deg, 120deg, 240deg), while an analogous palette takes hues within a 30-60 degree range of a base color. The HSL model also makes it trivial to create monochromatic palettes by varying lightness at a fixed hue, producing the light-to-dark variations essential for UI design systems.
HSL to RGB Conversion: The Math Behind the Colors
Converting HSL to RGB involves a series of mathematical steps that any color generation tool must implement. First, if saturation is 0%, the color is gray and RGB values are simply the lightness value scaled to 0-255. For non-zero saturation, the algorithm computes a chroma value (C = (1 - |2L - 1|) * S), then maps the hue to a sector (0-5) on the RGB cube. The intermediate value X = C * (1 - |(H/60deg) % 2 - 1|) provides the second-largest channel. Finally, a match value (m = L - C/2) shifts all channels to the correct lightness. The JavaScript implementation typically looks like: const C = (1 - Math.abs(2 * L - 1)) * S; const X = C * (1 - Math.abs((H / 60) % 2 - 1)); const m = L - C / 2; followed by a sector-based switch assigning (R,G,B) primed values then adding m. The reverse conversion (RGB to HSL) normalizes RGB values to [0,1], finds min and max, computes lightness as (max+min)/2, saturation as delta/(1-|2L-1|), and hue based on which channel is the maximum. Understanding these conversions is essential when building color tools, as different applications (browser rendering, print, image processing) operate in different color spaces and require accurate bidirectional conversion.
Color Difference and DeltaE: Measuring Perceptual Distance
Not all color differences are perceived equally by the human eye. The Euclidean distance in RGB space (sqrt((R1-R2)^2 + (G1-G2)^2 + (B1-B2)^2)) poorly correlates with perceived difference — two colors with the same RGB distance can appear nearly identical or very different depending on their position in the color space. This is why color science developed DeltaE (ΔE) metrics. The simplest is CIE76 (ΔE*ab), using the CIE L*a*b* color space where Euclidean distance better approximates perceptual difference. CIEDE2000 (ΔE00) is the current industry standard, incorporating corrections for lightness, chroma, and hue weighting, as well as compensation for the blue region and neutral colors. A ΔE00 value below 1.0 is imperceptible to most viewers, 1.0-2.0 is noticeable only on close inspection, 2.0-5.0 is clearly visible, and above 5.0 is perceived as completely different colors. For palette generation, target a minimum ΔE00 of at least 3-5 between adjacent palette colors to ensure they are visually distinguishable. Tools that need to maintain color identity across lighting conditions (like brand color specifications) should use ΔE00 measurements to define acceptable tolerances.
WCAG Contrast Ratios and Accessible Color Schemes
The Web Content Accessibility Guidelines (WCAG) 2.1 define specific contrast ratios for text and visual elements to ensure readability for users with visual impairments. The contrast ratio is calculated using the relative luminance formula: L = 0.2126 * R_lin + 0.7152 * G_lin + 0.0722 * B_lin, where each channel is first converted from sRGB to linear RGB. For normal text (under 18pt or 14pt bold), WCAG AA requires a minimum contrast ratio of 4.5:1 against the background. Large text (at least 18pt or 14pt bold) requires 3:1. WCAG AAA raises these to 7:1 for normal text and 4.5:1 for large text. User interface components and graphical objects must also meet 3:1 against adjacent colors. When generating color palettes for accessibility, ensure that all text-background pairs in your design system pass at least WCAG AA. Tools should avoid placing colors with similar lightness adjacent to text, as contrast is determined primarily by lightness difference rather than hue or saturation differences. A practical approach is to generate palettes with a minimum lightness difference of 30-40 points between text and background colors.
Color Blindness: Designing Palettes for All Users
Approximately 8% of males and 0.5% of females have some form of color vision deficiency (CVD). Deuteranopia (green-blind) and protanopia (red-blind) are the most common forms, affecting the ability to distinguish between red and green hues. Tritanopia (blue-yellow blindness) is rarer. When generating color palettes, relying solely on hue differences between red and green creates accessibility barriers. Effective strategies include: using differences in lightness instead of hue alone to convey information; incorporating texture, patterns, or labels alongside color coding; choosing color schemes that span the hue wheel (blue-orange combinations work well for color-blind users); and testing generated palettes with CVD simulation tools. The Palette mode in this tool allows locking individual colors while regenerating, letting designers iteratively refine toward accessible combinations. For data visualization, use colorblind-safe palette recommendations like those from ColorBrewer or Wong's Nature Methods palette, which select colors discriminable across all common forms of CVD.
Random Palette Generation: Algorithms and Best Practices
Generating visually appealing random color palettes requires more sophistication than simply picking random RGB values. A robust algorithm starts by selecting a random base hue, then generates palette members using harmonic relationships: analogous (±15-30deg), complementary (±150-180deg), split-complementary (base, base+150deg, base+210deg), triadic (0deg, 120deg, 240deg), or tetradic (0deg, 90deg, 180deg, 270deg). Saturation and lightness should be constrained to ranges that ensure readability — avoid very low saturation (colors appear muddy) and extreme lightness values (colors near white or black lose distinction). For a 5-color palette, a common strategy uses one dominant hue at full saturation and medium lightness, two supporting analogous hues at slightly reduced saturation, and two neutral or complementary accent colors. Adding slight randomness to each color's exact hue (±5deg) creates visual interest while maintaining harmony. The tool's Lock/Unlock mechanism lets users pin pleasing colors found during random generation, building a palette incrementally. For print design, also consider converting to CMYK and checking gamut boundaries, as some vibrant screen colors cannot be reproduced in print.