Random color generator

Press the space bar for a fresh five-color palette. Lock the colors you like and keep going.

Press the space bar for new colors. Tap a code to copy it.

How to use the random color generator

  1. Press the space bar or tap Generate for new colors.
  2. Tap the lock on a color to keep it while the others change. Tap it again to unlock.
  3. Tap a color code to copy it. Switch between HEX, RGB and HSL under Format.
  4. Choose Harmonious for palettes that go together, or Random for any color at all.

Color codes explained

  • HEX, like #3A7BD5: red, green and blue as two-digit hexadecimal (base 16) numbers. 3A is 58, 7B is 123 and D5 is 213. Used in web design and most design apps.
  • RGB, like rgb(58, 123, 213): the same red, green and blue amounts from 0 to 255.
  • HSL, like hsl(215, 65%, 53%): hue (0 to 360 degrees around the color wheel), saturation and lightness. Easiest for making a color lighter or darker: change only the last number.

All three describe exactly the same color; flipj converts between them when you switch Format. HSL values are rounded to whole numbers, so converting back can be one step out.

How many colors are there?

Each of red, green and blue has 256 levels, so there are 256 × 256 × 256 = 16,777,216 RGB colors. That is the same as the number of six-digit hex codes, because each pair of hex digits also has 256 values (16 × 16), and 166 = 16,777,216. Only 256 of them are pure greys, where red, green and blue are equal, from #000000 to #FFFFFF.

In Random mode every one of those colors has the same chance, so a palette of five can come out 1.33 × 1036 ways. Unlocked colors are replaced with each press; locked ones stay exactly as they are.

Harmonious or random?

Random picks red, green and blue independently, which gives some clashing, muddy or neon results. That is useful for inspiration and for testing, but palettes rarely look good on their own.

Harmonious works in HSL instead. It chooses a random starting hue, then steps around the color wheel by between 18 and 45 degrees (plus a few degrees of variation) from one swatch to the next, so the five hues are related. Saturation is kept between 45% and 79%, and the five swatches get five different lightness bands, roughly 28%, 42%, 56%, 70% and 84%, in a random order. The result is a set of related colors from dark to light, which is usually what a website, slide deck or poster needs: something dark for text, something light for backgrounds and a few colors in between.

Contrast: will text be readable?

The Web Content Accessibility Guidelines (WCAG 2.2) ask for a contrast ratio of at least 4.5:1 between normal text and its background, and 3:1 for large text (18 point, or 14 point bold); 7:1 meets the stricter AAA level (W3C). The ratio compares the relative luminance (perceived brightness) of the two colors and runs from 1:1 for identical colors to 21:1 for black on white.

ColorRatio with white textRatio with black text
#3A7BD54.22:14.97:1
#5B37F06.46:13.25:1
#FFBF1F1.65:112.72:1
#22C55E2.28:19.22:1
#E11D484.70:14.47:1
#7676764.54:14.62:1

We checked all 16,777,216 colors with the WCAG formula. 6,113,258 of them (36%) reach 4.5:1 with white text and 10,956,065 (65%) with black text, and every single color reaches it with one or the other: the hardest case still manages 4.58:1. So whatever color the generator gives you, either black or white text will be readable on it. Bright yellows and greens need black text; deep blues, purples and reds need white.

Turning a palette into a design

  • Lock as you go: keep the one color you love, then press the space bar until the rest fit around it.
  • Give each color a job: background, text, one accent for buttons and links, and one or two for highlights. Most designs need fewer colors than you think.
  • Check text on each background against the contrast table above before you commit.
  • Copy the codes as you go: palettes are not saved, so a new generate or a page reload replaces unlocked colors.
  • Need a random choice, not a palette? Put color names on the wheel for a game or a team colour.

Questions

How many colors are there in RGB?

16,777,216: 256 levels each of red, green and blue.

How do I copy a color code?

Tap the code under any color and it's copied to your clipboard.

What contrast ratio does text need?

WCAG 2.2 asks for at least 4.5:1 for normal text and 3:1 for large text. 7:1 meets the stricter AAA level.

Is the Harmonious mode random?

Yes. The starting hue, the spacing between hues, the saturation and the order of the lightness bands are all random, but kept within ranges that tend to go together.

Are my palettes saved?

No. Copy the codes you want to keep. Locked colors stay put only until you reload the page.

What is the difference between HEX and RGB?

Nothing but the notation. #3A7BD5 and rgb(58, 123, 213) are the same color, written in base 16 and base 10.

More random tools

See all 29 tools