Random color generator
Random colors with hex, RGB and HSL codes
Press the button for a random color, or choose several for a palette. Copy any hex code with one tap.
Ready
Press Pick colors.
How it is drawn: your browser's crypto.getRandomValues supplies random 32-bit numbers, and any value that would make one result more likely than another is thrown away and drawn again, so each of the 16,777,216 colors that a six-digit hex code can name has the same chance.
Recent results
Nothing yet. Results from this visit show here; they are not saved.
How a color is picked
A screen color is usually written as a hex code: a # and six digits from 0 to F, two each for red, green and blue. That allows 256 levels of each, or 16,777,216 colors in all. The page draws one whole number in that range with your browser's crypto.getRandomValues, every number equally likely, and writes it as a hex code. There is no list of named colors behind it, so every color has the same chance, including dull greys and browns.
The other values
- RGB gives the red, green and blue levels from 0 to 255, worked out from the hex code.
- HSL gives hue (0 to 359 degrees round the color wheel), saturation and lightness, rounded to whole numbers. Rounding means two very close colors can show the same HSL.
- Contrast is the ratio between the color and white or black, worked out with the formula in the Web Content Accessibility Guidelines (WCAG 2). WCAG asks for at least 4.5 to 1 for normal text. The sample text on each swatch uses whichever of black or white contrasts more.
Screens differ
The same hex code can look a little different from one screen to another, and printed colors work differently again. Treat the swatch as a guide, and check on paper before a print job.
Ideas
Use it to break a creative block, pick a theme for a party or class project, test a design against odd colors, or play a guess-the-hex game. Press "Copy" under a swatch to copy its hex code. Recent colors for this visit are listed below and are not saved.