Random Color Generator

Press Generate for random colors with their hex, RGB and HSL codes and their contrast ratio against white and black text. Choose any color, pastel, bright or dark styles, or an analogous or complementary palette, and copy a hex code with one tap. Any color mode picks from all 16,777,216 RGB colors.

Hex and RGBPalettes

How the random color generator works

Each color is made by picking random numbers. In Any color mode, the red, green and blue values are each a random whole number from 0 to 255, so there are 256 × 256 × 256 = 16,777,216 possible colors. The other styles pick a random hue (0° to 360°) and keep saturation and lightness in a range: high lightness for pastels, low for dark colors. Palette modes space the hues so the colors go together.

Color codes explained

  • Hex: #RRGGBB, each pair a base-16 number from 00 to FF (0 to 255). #FF0000 is pure red.
  • RGB: rgb(255, 0, 0), the amounts of red, green and blue light.
  • HSL: hsl(0, 100%, 50%), hue as an angle on the color wheel, saturation and lightness as percents.

Converting hex to decimal

Each hex digit is a power of 16. 0xC8 = 12 × 16 + 8 = 200. So #C8A2FF is rgb(200, 162, 255).

Contrast ratio

Each swatch shows its contrast ratio with white and black text, from 1:1 (no contrast) to 21:1 (black on white). WCAG 2.1 asks for at least 4.5:1 for normal text and 3:1 for large text. The text on each swatch uses whichever of black or white contrasts more.

Uses

  • Design palettes for slides, posters and websites.
  • Random team colors for class games.
  • Art prompts and drawing challenges.
  • Teaching base-16 numbers and coordinates in color space.

Check a pair of colors with the color contrast checker.

Color codes quiz: 10 questions

Test yourself with 10 multiple-choice questions. Choose an answer and press Submit to see if you are right and why. Your score appears at the end.

Question 1 of 10
1. How many values can each RGB channel take?

Found a mistake? Let us know!

2. How many colors are possible with 8-bit RGB?

Found a mistake? Let us know!

3. What is hex FF in decimal?

Found a mistake? Let us know!

4. What is hex C8 in decimal?

Found a mistake? Let us know!

5. #000000 is:

Found a mistake? Let us know!

6. The hue opposite 30° on the color wheel is:

Found a mistake? Let us know!

7. WCAG 2.1 minimum contrast for normal text is:

Found a mistake? Let us know!

8. The contrast ratio of black on white is:

Found a mistake? Let us know!

9. rgb(0, 0, 255) is:

Found a mistake? Let us know!

10. A random hue is chosen from 0° to 360°. The chance it is between 0° and 90° is:

Found a mistake? Let us know!

Frequently asked questions

How many colors can a random color generator make?

With 0 to 255 for each of red, green and blue, there are 256³ = 16,777,216 colors.

What is a hex color code?

A six-digit base-16 code, #RRGGBB, giving the red, green and blue amounts from 00 to FF.

How do I copy a color?

Press Copy hex under the swatch.

What is a good contrast ratio for text?

At least 4.5:1 for normal text and 3:1 for large text, under WCAG 2.1.

Can I make a matching palette?

Yes. Choose Analogous for neighboring hues or Complementary for opposite hues on the color wheel.

Sources

Related calculators

Browse all calculators

Related to This Article

What people say about "Random Color Generator - Effortless Math"?

No one replied yet.

Leave a Reply