User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
1โ€“100
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

About

Hex color codes encode red, green, and blue channels into a six-character string prefixed with #, where each pair ranges from 00 to FF (0 - 255 in decimal). The total color space contains 16,777,216 unique values (2563). Selecting colors by intuition alone introduces bias toward familiar hues and ignores large regions of the gamut. This generator uses crypto.getRandomValues to produce uniformly distributed samples across the full sRGB cube, eliminating the weak periodicity of pseudo-random number generators.

Relative luminance is computed for each swatch so overlay text automatically switches between light and dark for readability, following WCAG 2.1 contrast guidelines. The tool approximates perceptual brightness only; it does not account for display gamma calibration or wide-gamut color spaces like DCI-P3. Pro tip: if you need harmonious palettes rather than pure random samples, lock one hue channel and randomize the others.

hex color generator random color color palette hex code color picker web colors design tools

Formulas

Each hex color encodes three channels. A random color is constructed by generating three independent bytes:

color = # + hex(R) + hex(G) + hex(B)

where R, G, B โˆˆ [0, 255] are unsigned 8-bit integers from crypto.getRandomValues.

To determine whether overlay text should be dark or light, relative luminance L is calculated per WCAG 2.1:

L = 0.2126 โ‹… Rlin + 0.7152 โ‹… Glin + 0.0722 โ‹… Blin

Each channel is linearized from sRGB:

{
Clin = Csrgb12.92 if Csrgb โ‰ค 0.04045Clin = (Csrgb + 0.0551.055)2.4 otherwise

where Csrgb = C255 for each channel. If L > 0.179, dark text is used; otherwise, light text is applied.

RGB to HSL conversion for the info display uses:

H = 60ยฐ ร— CoffsetCmax โˆ’ Cmin

where Coffset depends on which channel is dominant, S = Cmax โˆ’ Cmin1 โˆ’ |2L โˆ’ 1|, and L = Cmax + Cmin2.

Reference Data

Color NameHex CodeRGBLuminanceCommon Use
Black#0000000, 0, 00.000Text, borders
White#FFFFFF255, 255, 2551.000Backgrounds
Red#FF0000255, 0, 00.213Errors, alerts
Green#00FF000, 255, 00.715Success states
Blue#0000FF0, 0, 2550.072Links, primary actions
Cyan#00FFFF0, 255, 2550.787Accents, info badges
Magenta#FF00FF255, 0, 2550.285Creative highlights
Yellow#FFFF00255, 255, 00.928Warnings
Orange#FFA500255, 165, 00.482CTAs, notifications
Purple#800080128, 0, 1280.061Branding, luxury
Teal#0080800, 128, 1280.170Healthcare, fintech
Navy#0000800, 0, 1280.016Corporate, headers
Coral#FF7F50255, 127, 800.370Warm accents
Slate Gray#708090112, 128, 1440.208Neutral text
Goldenrod#DAA520218, 165, 320.420Premium accents
Tomato#FF6347255, 99, 710.306Destructive actions
Steel Blue#4682B470, 130, 1800.206Dashboard UI
Mint Cream#F5FFFA245, 255, 2500.978Light backgrounds
Indigo#4B008275, 0, 1300.031Dark themes
Chartreuse#7FFF00127, 255, 00.648Eco, energy brands

Frequently Asked Questions

Math.random uses a pseudo-random number generator (xorshift128+ in most engines) that is deterministic given a seed and has detectable periodicity. crypto.getRandomValues sources entropy from the operating system's CSPRNG, producing uniformly distributed bytes with no predictable pattern. For a color space of 16,777,216 values, the practical difference is subtle, but it eliminates clustering artifacts that can appear when generating thousands of colors in sequence.
The generator computes relative luminance using the WCAG 2.1 formula: each sRGB channel is linearized (gamma-decoded), then weighted as 0.2126ยทR + 0.7152ยทG + 0.0722ยทB. If the resulting luminance exceeds 0.179, the overlay text renders in dark (#1a1a2e); otherwise it renders in white (#ffffff). This threshold guarantees a minimum contrast ratio of approximately 4.5:1 against both light and dark backgrounds.
Yes. Adjacent hex values like #3A7CB2 and #3A7CB3 differ by 1 in the blue channel (178 vs 179 out of 255). On an 8-bit sRGB display, this 0.39% intensity change is below the just-noticeable difference threshold for most observers. On 6-bit panels (common in budget monitors), dithering may render them identically. The generator does not deduplicate visually similar results because perceptual similarity depends on display hardware.
All three encode the same color. Hex is a base-16 compact notation (#RRGGBB). RGB specifies decimal channel intensities from 0-255. HSL separates hue (0ยฐ - 360ยฐ), saturation (0% - 100%), and lightness (0% - 100%), making it easier to reason about color relationships. The generator displays all three formats for each swatch so you can copy whichever your project requires.
The generator always outputs full 6-digit hex codes for precision. A 3-digit shorthand like #F0A expands to #FF00AA by duplicating each nibble, which limits you to 4,096 colors (16ยณ) instead of the full 16,777,216 (256ยณ). The generated values are only expressible in shorthand when both nibbles per channel match (e.g., #AABB33 โ†’ #AB3), which occurs with probability (16/256)ยณ โ‰ˆ 0.024%.
WCAG 2.1 Level AA requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text. The contrast ratio between two colors is (L1 + 0.05)/(L2 + 0.05), where L1 and L2 are their relative luminances. This generator shows luminance for each color. To check a pair, compute the ratio manually or use the displayed luminance values. Random colors are unlikely to form accessible pairs without deliberate selection.