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.
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.
Quiz complete
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
Related to This Article
More math articles
- Adding and Subtracting Fractions with Unlike Denominators Calculator (with Steps)
- The Best Grade 7 Math Book for Colorado Students
- Free Grade 4 English Worksheets for Florida Students
- The Best Algebra 1 Book for Arkansas Students
- How to Prep for the AMC 10 and AMC 12 Math Competitions in 2027
- How to Solve Systems of Equations: 3 Methods Explained
- NYSTCE Mathematics Flashcards
- Disasters and Collective Response
- Deviance, Crime, Harm, and Social Definition
- Types Of Angles In Geometry


What people say about "Random Color Generator - Effortless Math"?
No one replied yet.