Create a random color in seconds and download the result as a RANDOMCOLOR file for quick reuse in your projects.
#3b82f6), RGB (rgb(59, 130, 246)), HSL (hsl(217, 91%, 60%)), or OKLCH (oklch(63.7% 0.187 259)). HEX and RGB target sRGB; OKLCH addresses the wider Display P3 / Rec.2020 gamuts in CSS Color 4.Random color is a creativity primitive — useful whenever you need a starting point you wouldn't have chosen yourself, a placeholder that won't bias later design decisions, or a controlled variable in test data. Pure random is rarely good design, but constrained random (locked hue, bounded saturation) is how most modern design-system tooling generates accent ramps.
hsl(hue, 60%, 50%) for consistent per-user colors.L=50% yellow looks brighter than HSL L=50% blue — and why OKLCH fixes it.| Property | HEX | RGB | HSL | OKLCH |
|---|---|---|---|---|
| Example | #3b82f6 |
rgb(59, 130, 246) |
hsl(217, 91%, 60%) |
oklch(63.7% 0.187 259) |
| Color space | sRGB | sRGB | sRGB | Oklab (perceptual) |
| Axes | red/green/blue (0-255) | red/green/blue (0-255) | hue/saturation/lightness | lightness/chroma/hue |
| Perceptually uniform | No | No | No (L=50% yellow ≠ L=50% blue) | Yes |
| Wide-gamut (P3/Rec.2020) | No | No (sRGB only) | No | Yes via oklch() |
| Alpha channel | #RRGGBBAA (8-digit) |
rgba() / rgb(... / a) |
hsla() / hsl(... / a) |
oklch(... / a) |
| Browser support | Universal | Universal | Universal | Chrome 111+, Safari 15.4+, Firefox 113+ |
| Best for | Static markup, design tokens | Canvas, image processing | Theming with intuitive axes | Modern design systems, accessible palettes |
| Use case | Strategy | Example output |
|---|---|---|
| Avatar fallback color | Hash user ID → hue; fix S=60%, L=50% | hsl(142, 60%, 50%) |
| Design-system accent | Random hue; fix OKLCH L=0.7, C=0.15 | oklch(70% 0.15 89) |
| Categorical chart palette (N colors) | Hues at 360/N spacing; fix L and C | oklch(70% 0.15 0), oklch(70% 0.15 72), ... |
| Pastel mood board | Random hue; H clamped, S=30-50%, L=80-90% | hsl(204, 40%, 85%) |
| Dark-mode background | Random hue; L=10-20%, low chroma | oklch(15% 0.02 240) |
| Brand exploration | Pure random across all axes | Anything — that's the point |
HSL exposes hue, saturation, and lightness as separate axes that map to how designers think. Want a darker version of a button color? Drop the L value. Want a less saturated background? Drop the S. With RGB you'd have to recompute all three channels. The catch: HSL lightness is mathematically defined, not perceptually uniform — a 50% L yellow looks dramatically brighter than a 50% L blue. For palette work where consistency matters, OKLCH solves what HSL only approximates.
OKLCH is built on the Oklab color space, which is calibrated against human vision. When you set L=0.7 in OKLCH, the perceived brightness stays roughly equal across every hue. In HSL, L=50% yellow appears far brighter than L=50% blue because HSL lightness is a midpoint between min and max RGB channels, not a perceptual measurement. OKLCH also exposes chroma (colorfulness) instead of saturation, and supports wider gamuts beyond sRGB. The trade-off is that OKLCH values look less round and memorable than hsl(120, 100%, 50%).
For sRGB colors, yes — #3b82f6 and rgb(59, 130, 246) produce identical pixels. HEX is more compact in markup; rgb() is required when you need a non-integer alpha via rgb(59 130 246 / 0.5). They diverge for wide-gamut work: HEX has no notation for Display P3 or Rec.2020, while CSS Color 4 introduces color(display-p3 ...) and oklch() to address colors outside sRGB. Modern displays on iPhone 7+, recent Macs, and many newer Android phones can render colors HEX literally cannot encode.
Generate the random color, then check it against your background with a contrast tool. WCAG 2.1 AA requires 4.5:1 for body text and 3:1 for large text (18pt+, or 14pt+ bold); AAA bumps body to 7:1. If you're rolling random foregrounds, constrain OKLCH lightness to <0.45 against a white background or >0.7 against a black background — that gets you most of the way to 4.5:1 before formal checking.
Pure random samples uniformly across the entire color space and almost always produces ugly, clashing palettes. Constrained random — lock the hue and vary lightness, or fix lightness/chroma and vary hue — generates results that look palette-like because human color perception expects tonal coherence. Every production "random avatar color" system uses constrained random; nobody ships a UI that paints rgb(255, 0, 0) next to rgb(252, 250, 255).
Yes, with constraints. Random in OKLCH with L=0.55-0.65 and C=0.1-0.18 against a white background tends to land in the AA contrast zone. For deuteranopia/protanopia safety (red-green colorblindness), avoid hues 0-60 and 100-180 in the same palette — those collapse into similar perceived hues. Always run the result through a color-blindness simulator before shipping a categorical palette.
oklch() color work in older browsers?OKLCH ships in Chrome 111+ (March 2023), Safari 15.4+ (March 2022), and Firefox 113+ (May 2023). For older browser support, provide a fallback in the same declaration: color: #3b82f6; color: oklch(63.7% 0.187 259); — browsers that don't understand the second declaration keep the first. Tailwind CSS v4 defaults to OKLCH for its built-in palette for this exact reason.
If your generator uses Math.random() seeded from a timestamp at page load, refreshing within the same millisecond can return the same value. Most generators (this one included) seed from the high-resolution performance.now() clock or crypto.getRandomValues() for genuine per-click variance. If you need deterministic colors (avatar by username, repeated tests), hash an input string to seed instead of relying on Math.random().
If you generate oklch(63.7% 0.187 259) but need it as HEX or RGB for a legacy stylesheet, paste it into the color converter — it accepts any of HEX, RGB, HSL, OKLCH, or CMYK and emits all the others side-by-side with a live swatch preview.