Random Color
generator.
Draw random colors for a palette, lock the ones you like, and see which text reads on each.
- Locked
- 0 of 5
- AAA with black or white
- 2 of 5
- Strongest pair
- 8.0:1
2 of 5 colors reach AAA (7:1) with black or white text. The weakest, #BD22E0, gets 4.6:1 with white text, enough for AA. Inside the palette, #F3C9EB and #710A2E make the strongest pair at 8.0:1 (AAA).
Where the colors sit
Hue across, lightness up5 colors by hue and lightness. 1: #F3C9EB, light magenta, hue 311°, lightness 87%; 2: #FD2B30, red, hue 359°, lightness 58%; 3: #F05C70, red, hue 352°, lightness 65%; 4: #710A2E, dark red, hue 339°, lightness 24%; 5: #BD22E0, purple, hue 289°, lightness 51%. Any color covers every hue and lightness.
The palette as a table
The palette as a table
| Color | RGB | HSL | |
|---|---|---|---|
| 1. #F3C9EB light magentaRGB rgb(243, 201, 235)HSL hsl(311, 64%, 87%) | rgb(243, 201, 235) | hsl(311, 64%, 87%) | Black 14.3:1, AAA |
| 2. #FD2B30 redRGB rgb(253, 43, 48)HSL hsl(359, 98%, 58%) | rgb(253, 43, 48) | hsl(359, 98%, 58%) | Black 5.5:1, AA |
| 3. #F05C70 redRGB rgb(240, 92, 112)HSL hsl(352, 83%, 65%) | rgb(240, 92, 112) | hsl(352, 83%, 65%) | Black 6.4:1, AA |
| 4. #710A2E dark redRGB rgb(113, 10, 46)HSL hsl(339, 84%, 24%) | rgb(113, 10, 46) | hsl(339, 84%, 24%) | White 11.7:1, AAA |
| 5. #BD22E0 purpleRGB rgb(189, 34, 224)HSL hsl(289, 75%, 51%) | rgb(189, 34, 224) | hsl(289, 75%, 51%) | White 4.6:1, AA |
Text on these colors
Pairs inside the palette
| Pair | Ratio | Level |
|---|---|---|
| #F3C9EBand#710A2E | 8.0:1Level AAA | AAA |
| #F05C70and#710A2E | 3.6:1Level AA large text only | AA large text only |
| #F3C9EBand#BD22E0 | 3.2:1Level AA large text only | AA large text only |
| #FD2B30and#710A2E | 3.1:1Level AA large text only | AA large text only |
| #F3C9EBand#FD2B30 | 2.5:1Level Fails AA | Fails AA |
| #710A2Eand#BD22E0 | 2.5:1Level Fails AA | Fails AA |
WCAG 2.2 asks for 4.5:1 for normal text (AA), 7:1 for AAA, and 3:1 for large text, at least 18 point or 14 point bold. Black or white text never falls below 4.58:1 on any color.
Keyboard shortcuts
- G draws new colors for every slot that is not locked.
- 1 to 9 lock that color, or release it.
- C copies the codes in the notation shown.
- They work when no box or button has focus; click an empty part of the page first if you were typing.
How it's worked out
With the Any color style, red, green and blue are each a whole number from 0 to 255, drawn on their own. That makes 16,777,216 possible colors, and each one is equally likely.
The numbers come from your browser’s cryptographic generator, crypto.getRandomValues. A plain remainder would make some values a little more common than others, so a raw draw that falls in the uneven top slice is thrown away and drawn again. This is called rejection sampling, and it leaves no bias.
The other styles work in HSL: hue, saturation and lightness. Hue is any whole degree from 0 to 359, while saturation and lightness stay inside the style’s range. Pastel keeps lightness from 80% to 90%, Vivid from 45% to 60% and Dark from 12% to 30%. That is why a style feels consistent even though every hue can turn up.
For text, the tool uses relative luminance from WCAG, which weights green far more than blue because our eyes do. The contrast ratio compares the lighter color with the darker one.
Here is the luminance of the lighter color and of the darker one, each from 0 for black to 1 for white. Each swatch shows whichever of black or white text scores higher. Where the two scores meet, the ratio is the square root of 21, so black or white text never gets less than 4.58:1 on any color.
Worked examples
Maya keeps one red and redraws the rest for a poster
Maya draws five vivid colors: #9EF702, #EF3E58, #EF2C1A, #E81721, #7BEB47. She likes the second one, #EF3E58, a red, so she locks it and draws again. The new set is #DB530F, #EF3E58, #47EB89, #1CD981, #2BE33A, with her red still in place.
Every color takes black or white text at AA or better. The weakest is #DB530F, with black text at 5.2:1 (AA). Inside the palette, though, the strongest pair is #DB530F and #47EB89 at only 2.5:1, which fails even the large text level. Bright, saturated colors rarely differ enough in luminance for that, so she should set her headline in black or white, not in one palette color on another.
Leo picks eight pastel colors for tags
Leo needs eight soft colors for task labels. The Pastel style gives #F4EBB3, #D4F3CE, #F2ABB8, #DBD7F4, #BCE6D4, #F6C5C1, #B2D3EB, #B5F2EE.
All eight take black text. The lowest score is #F2ABB8, a light red, with black text at 11.2:1 (AAA). Pastels are light by design, so dark text on them is easy to read, and the label names stay sharp even at small sizes.
Four dark colors for a dark theme
The Dark style draws hsl(84, 61%, 12%), hsl(306, 69%, 14%), hsl(106, 57%, 12%), hsl(78, 41%, 27%). Every one takes white text.
HSL lightness and contrast do not line up. hsl(306, 69%, 14%) has the higher lightness, 14%, yet gets 16.2:1 with white. hsl(84, 61%, 12%), at 12%, gets 13.6:1. The first color looks darker to the eye because it holds less green, and the luminance formula counts that while HSL does not.
Reading your result
| Level | Normal text | Large text |
|---|---|---|
| AA | 4.5:1 | 3:1 |
| AAA | 7:1 | 4.5:1 |
Large text means at least 18 point, or 14 point in bold. In CSS pixels that is about 24 px, or about 18.5 px in bold. Icons and borders that people need to see should reach 3:1 against what is next to them.
Since every color passes AA with black or white, the levels that tell colors apart are AAA and the pairs inside the palette. Mid-tone colors, such as a pure red, sit near the 4.58:1 floor. Very light and very dark colors pass 7:1 with ease.
The ratio is cut, not rounded. WCAG compares the exact value, so 4.499:1 fails a 4.5:1 rule even though it looks like 4.5 when rounded. The figures here are cut to one place for the same reason.
The name is a rough guide. Names such as light blue or dark green come from the hue and lightness. They help you talk about a color, but the hex code is the exact value to share.
Common mistakes
- Trusting HSL lightness for text. Pure yellow and pure blue are both 50% lightness in HSL. Yet yellow takes black text at 19.5:1 (AAA), and blue takes white text at 8.5:1 (AAA). Check the ratio, not the lightness number.
- Putting one palette color on another. Random colors often share a similar luminance. The pairs table shows which two colors, if any, can carry text on each other.
- Writing your own random hex code with a shortcut. A common snippet multiplies a random fraction by 16,777,215 and converts it to hex. It can never give white, FFFFFF, and it drops leading zeros, so some codes come out with five digits.
- Expecting the same color everywhere. A hex code names an sRGB color. Screens differ in brightness and range, and print uses inks that cannot match every bright screen color, so check a brand palette on the devices that matter.
- Sending a screenshot instead of the codes. A screenshot can shift colors through compression and display settings. Send the share link or the exported table.