About this tool
Need placeholder colours for a mock-up, tag or avatar backgrounds, chart series, or just inspiration? This random color generator makes as many colours as you like, previews them as swatches and gives you the code in HEX, RGB, HSL or OKLCH. Each swatch shows “Aa” in black or white, whichever is easier to read on it.
How to use it
- Pick a style: Any is fully random; the others keep saturation and lightness in a band, so the set looks consistent.
- Choose the format you want to paste into your CSS or design tool.
- Copy a single colour with its row button, or copy the whole list. Press G for a new set.
Styles
| Style | Saturation | Lightness | Good for |
|---|---|---|---|
| Pastel | 55–85% | 78–88% | Tag and avatar backgrounds behind dark text |
| Vivid | 75–100% | 45–58% | Chart series, highlights, call-outs |
| Dark | 35–70% | 14–28% | Backgrounds behind white text, dark themes |
| Light | 30–70% | 86–94% | Subtle section and card backgrounds |
| Grayscale | 0% | 8–92% | Neutral placeholders and wireframes |
To convert one of these colours to other formats, check its contrast or build tints and shades, open it in the Color Converter.
Random colours in code
// Random HEX colour
const hex = '#' + crypto.getRandomValues(new Uint8Array(3))
.reduce((s, b) => s + b.toString(16).padStart(2, '0'), '');
// Random pastel: fixed saturation and lightness, random hue
const hue = crypto.getRandomValues(new Uint32Array(1))[0] % 360;
const pastel = `hsl(${hue} 70% 84%)`;
FAQ
How do I generate a random HEX color?
Leave the format on HEX and click Generate. Each code is six hexadecimal digits, like #3fa7c2, ready for CSS.
How do I get random pastel colors?
Choose the Pastel style. Saturation and lightness stay in a soft range while the hue is random.
Which format should I use?
HEX is the most widely accepted. RGB is useful in code, HSL is easy to adjust by hand, and OKLCH gives the most even-looking palettes in modern CSS.
Are the colors accessible?
Each swatch shows whether black or white text reads better on it. For exact WCAG contrast ratios, open the color in the Color Converter.