How to generate a random color

Generate an integer from 0 to 255 for each red, green, and blue channel, then format the result as RGB, HEX, or HSL. Use randomness for exploration or test data, not as a substitute for a designed palette.

Open the random color generator

Generate three random RGB channels

R, G, B = random whole numbers from 0 through 255

Each set of three channels identifies one opaque sRGB color. For example, random values 51, 102, and 153 produce rgb(51, 102, 153), which is #336699.

Sampling all three channels independently makes every 24-bit RGB combination possible. It does not make every perceived hue, lightness, or saturation equally likely.

Convert the result to useful formats

HEX is compact for CSS and design tools. RGB exposes the source channels. HSL is helpful when you want to adjust the generated hue, saturation, or lightness after choosing a starting point.

FormatSame example color
HEX#336699
RGBrgb(51, 102, 153)
HSLhsl(210 50% 40%)

Good uses for random colors

  • Explore starting points when you have no required base hue.
  • Create varied placeholder data for charts or component testing.
  • Run visual stress tests with very light, dark, or saturated values.
  • Pick one candidate, then build deliberate tints, shades, or relationships around it.

Copy any color you want to keep before generating again. A random sequence may not be reproducible, and duplicates are possible.

Do not treat random output as a finished palette

Independently generated colors are not guaranteed to coordinate. They may also fail text contrast requirements or be hard to distinguish for some users. Assign roles, reduce the list, and test the final combinations.

For related colors, start with the Color Palette Generator. For text and background pairs, use the Color Contrast Checker.

Generate colors with ToolPixels

The free Random Color Generator creates up to 20 opaque sRGB colors in your browser and shows copyable HEX, RGB, and HSL values for each.

Generate random colors