A random color generator that gives you usable colours
The Random Color Generator creates between 1 and 50 random colours at a time and shows each one as a large swatch with its HEX, RGB and HSL codes. Tap any code to copy it, lock the colours you like, and generate again until the whole set works together.
Pure randomness tends to produce muddy browns and olive greens, so you can also steer the result. Choose pastel, vibrant, dark, light or greyscale, or limit the colours to a hue range such as “blues and teals”. Under the hood those styles use the OKLCH colour space, which matches how bright and colourful people actually perceive a colour.
Designers use it to break out of habits, developers to fill placeholder UI and test data, teachers and artists for warm-up exercises, and anyone who just wants a fresh colour for a poster, a slide or a bedroom wall. Everything runs in your browser using its cryptographic random number generator; nothing is uploaded.
How to use the Random Color Generator
- Choose a Colour style: any colour, pastel, vibrant, dark, light or greyscale.
- Set How many colours you want, from 1 to 50.
- Optionally tick Limit to a hue range and drag the From and To sliders — the bar previews the hues you will get.
- Press Generate colours (or the Space bar). Tap a HEX, RGB or HSL code on a swatch to copy it.
- Click the padlock on colours you want to keep, then generate again to replace only the unlocked ones.
- Pick CSS, JSON or HEX list under Export palette and copy or download the code.
Random Color Generator features
Six colour styles
Any colour samples all 16.7 million sRGB values equally; the other styles target a lightness and saturation band so results fit a purpose.
Perceptually even hue ranges
Hue limits work in OKLCH, so a 200°–250° range really looks evenly spread instead of bunching up the way HSL does.
Readable labels on every swatch
Text on each swatch is black or white — whichever gives the higher WCAG contrast ratio, always at least 4.5:1.
Lock and regenerate
Keep the colours you like and reroll the rest, one swatch or the whole set at a time.
CSS and JSON export
Copy a :root block of custom properties, a JSON array with HEX, RGB and HSL values, or a plain HEX list.
Recent palettes
Your last ten palettes are kept on this device so you can bring back a set you skipped past.
Why OKLCH makes better random colours
HSL is convenient but not perceptual: at the same “lightness” value, yellow looks far brighter than blue, and the green part of the hue wheel takes up a huge slice. Random HSL colours therefore look uneven. OKLCH, published by Björn Ottosson in 2020 and now part of CSS Color Level 4, describes a colour by perceived lightness (L), chroma or colourfulness (C) and hue angle (H). Equal steps in L look like equal steps in brightness for every hue.
Each style picks L and C inside a band, then the colour is mapped back into the sRGB gamut your screen can show. Vibrant colours go further: for each random hue the generator finds the lightness where that hue can be most saturated and stays close to it, so yellows come out bright and blues deep instead of washed out.
What each style produces
| Style | OKLCH lightness | Chroma | Good for |
|---|---|---|---|
| Any colour | Any (uniform RGB) | Any | True randomness, test data, games |
| Pastel | 0.84–0.93 | 0.045–0.10 | Backgrounds, stationery, baby and spring themes |
| Vibrant | Near each hue’s peak | 86–100% of the maximum | Logos, charts, accents, posters |
| Dark | 0.24–0.42 | 0.03–0.13 | Dark-mode surfaces, text, moody palettes |
| Light | 0.90–0.97 | 0.015–0.05 | Page backgrounds, cards, subtle tints |
| Greyscale | 0.12–0.97 | 0 (neutral) | Neutrals, shadows, UI greys |
How the readable text colour is chosen
For every swatch the tool calculates the colour’s relative luminance with the WCAG 2 formula — 0.2126 × R + 0.7152 × G + 0.0722 × B on linearised channel values — and compares the contrast ratio against black and against white. The higher one wins. Because of how the formula works, the better of the two is always at least about 4.58:1, which passes WCAG AA for normal text.
If you plan to put coloured text on a coloured background, check the exact pair in the Contrast Checker. To turn one random colour into a set of tints and shades, use the Color Shades Generator, or build a harmony around it with the Color Palette Generator.
Tips for building a palette from random colours
- Generate with “Vibrant” until one accent colour stands out, lock it, then switch to “Light” or “Dark” to fill in backgrounds around it.
- For brand work, keep one or two saturated colours and let the rest be near-neutrals — too many vivid colours compete for attention.
- Use a narrow hue range (30–60°) for calm analogous palettes, or a wrapped range such as 330° → 30° for warm reds and pinks.
- Convert a favourite into other formats, such as CMYK or OKLCH, with the Color Converter.
Random Color Generator FAQ
How does the random color generator pick colours?
It uses your browser’s cryptographic random number generator (crypto.getRandomValues) with rejection sampling, so every value is equally likely. In “Any colour” mode each of the red, green and blue channels is an independent whole number from 0 to 255, giving 16,777,216 possible colours.
Can I generate only pastel or only dark colours?
Yes. Choose Pastel, Vibrant, Dark, Light or Greyscale in the Colour style menu. You can combine any of them, except greyscale, with a hue range — for example pastel colours between 180° and 260° for soft blues.
What is the difference between HEX, RGB and HSL?
They describe the same colour. HEX is a six-digit hexadecimal code (#3A7BD5), RGB lists the red, green and blue amounts from 0 to 255, and HSL gives hue in degrees with saturation and lightness as percentages. All three work in CSS.
How do I keep a colour I like?
Click the padlock on its swatch. Locked colours stay in place when you generate again, and “Unlock all” releases them. Your last ten palettes are also listed under Recent palettes.
How do I export the colours to CSS?
Under Export palette choose CSS to get a :root block of custom properties (--color-1, --color-2 …), then copy it or download palette.css. JSON and a plain HEX list are also available.
Are the colours saved or sent anywhere?
No. Colours are generated in your browser. Recent palettes are stored only in this browser’s local storage, and “Clear history” removes them.