Random Color Generator
Generate random hex and RGB colors with one click.
This tool runs entirely in your browser. Your files are never uploaded to a server.
#b40cba
rgb(180, 12, 186)
#8fe3c7
rgb(143, 227, 199)
#0cc27a
rgb(12, 194, 122)
#8eb9f9
rgb(142, 185, 249)
#b03237
rgb(176, 50, 55)
#b83fee
rgb(184, 63, 238)
What this tool does
Generates six random colors at once, each shown as a swatch alongside its hex code (#rrggbb) and RGB value (rgb(r, g, b)), so you can preview and copy either format.
How to use it
Click "Generate random colors" to replace all six swatches with a fresh set. Click the hex or RGB text under any swatch to copy that value to your clipboard — you can regenerate as many times as you like.
Worked example
The hex-to-RGB conversion works the same way no matter which color you land on: the hex code #3498db splits into byte pairs 34, 98, and db, which equal 52, 152, and 219 in decimal — so the tool displays rgb(52, 152, 219) next to that hex value.
Method
Each color starts as a random integer between 0 and 16,777,215 (0xffffff, the highest 24-bit value) produced by Math.random(), then converted to a 6-digit hexadecimal string padded with leading zeros. The matching RGB value comes from the same integer by extracting its red, green, and blue bytes with bit shifts, not from three separately generated numbers.
Formats and copying
Each swatch shows hex and RGB side by side because different tools expect different formats — CSS and design software generally accept either, but some contexts, like older email templates, only support hex. Both values have their own one-click copy button.
Limitations
Colors come from Math.random(), a fast general-purpose generator, not the cryptographically secure crypto.getRandomValues() that tools like the Random String Generator use — fine for design inspiration, but not for anything security-sensitive. Colors are also drawn independently across the full RGB space with no palette logic, so a set of six can include harsh combinations or colors with poor contrast against white or black text. For colors chosen to work well together, use the Color Palette Generator instead.
Privacy and processing
Every color is generated locally in your browser using JavaScript's built-in random number generator. Nothing is uploaded or stored on a server.
Frequently Asked Questions
- How random are these colors?
- Each color is chosen uniformly at random across the full RGB color space — no bias toward any particular hue.
- What formats are shown?
- Both hex (#rrggbb) and RGB (rgb(r, g, b)) — click either to copy it.
- Can I generate a themed palette instead?
- For a more curated set of colors that work well together, try the Color Palette Generator instead.
- Is this safe to use for generating security keys or tokens?
- No — colors are generated with Math.random(), which is fast but not cryptographically secure. For random values used in security contexts, use a tool built on crypto.getRandomValues(), such as the Random String Generator.