Random Hex Code Generator
Random six-digit hex codes for colours, IDs and test data.
Generated numbers
Your numbers will appear here. Press Generate to start.
Generate random hexadecimal codes in the standard six-digit form — #A3F92C — used for colours in CSS, design tools and anywhere else a colour is written as text. The same values work as short opaque identifiers or as filler for test data. Every code is drawn from the full 16.7 million possibilities with no bias toward any part of the spectrum.
Why use this tool?
Ready to paste
Results arrive in the exact form CSS and design tools expect — a # followed by six uppercase hex digits, zero-padded so every code is the same length.
The whole colour space
All 16,777,216 values are equally likely. There is no clustering toward greys or any hue, which is what you want when the point is to sample the space evenly.
Unique batches
Generate a palette of distinct codes with no duplicates, up to 10,000 at a time.
Free and private
Generated in your browser with nothing sent anywhere, no account and no usage limit.
How this random hex code generator works
A six-digit hex code is just a number written in base 16. #000000 is zero and #FFFFFF is 16,777,215, with every colour in between corresponding to exactly one integer. So the generator draws an integer from that range using the same cryptographic source as the rest of the site and prints it in base 16, padded to six digits.
Padding is what makes the output usable. The number 255 is FF in hex, but the colour is #0000FF — drop the leading zeros and you have changed a blue into something that is not a valid colour at all. Every result here is padded to a full six characters.
Uppercase is a convention rather than a requirement; CSS treats #a3f92c and #A3F92C identically. Uppercase is used here because it keeps 0 and O, and 8 and B, distinguishable at small sizes — which matters when you are reading a code off a screen to type it somewhere else.
Worth knowing: uniformly random colours are not the same as good colours. An even sample of the RGB cube produces a lot of muddy mid-tones, because most of that cube is muddy. Random hex is excellent for test data and identifiers, and a poor way to choose a palette.
How to use it
Step 1: Choose how many
Enter a quantity from 1 to 10,000.
Step 2: Decide on duplicates
Leave Unique only ticked for a set of distinct codes.
Step 3: Generate and copy
Press Generate, then select any code to copy it complete with its # prefix.
Example usage
- Placeholder colours in a mock-up
- A dozen distinct codes to fill a design before the real palette exists, so blocks are visually separable.
- Test data for a colour field
- A few thousand valid hex values exported as CSV to exercise validation and storage.
- Short opaque identifiers
- Six hex digits give 16.7 million possibilities in six characters — more compact than a decimal number of the same strength.
Frequently asked questions
How many hex colours are there?
16,777,216 — that is 256 possible values for each of red, green and blue. Every one of them is equally likely to be drawn here.
Can I use these as CSS colours?
Yes, directly. The output is the standard #RRGGBB form that CSS, design tools and most colour pickers accept. There is no alpha channel; these codes are fully opaque.
Why are the letters uppercase?
Purely for legibility — hex is case-insensitive, so #a3f92c and #A3F92C are the same colour. Uppercase keeps 0 and O apart, and 8 and B, when you are reading a code off a screen.
Will random hex codes give me a good colour palette?
Generally no. Sampling the RGB cube evenly produces mostly muddy mid-tones, because that is what most of the cube contains. Random hex is ideal for test data and placeholders; for a palette you want a tool that works in a perceptual colour space and controls lightness and saturation deliberately.
Can I generate shorter hex codes?
This tool produces the six-digit form. The three-digit CSS shorthand (#ABC) only covers 4,096 colours — each digit doubled — so it is a small subset rather than a separate range.
Related tools
4 Digit Random Number Generator
Random codes from 0000 to 9999, zero-padded and ready to use as PINs or verification codes.
Random Number Generator
Set any minimum and maximum and draw as many numbers as you need.
Random Prime Number Generator
Random primes in any range, plus the full list of primes under 100.
Browse every tool in Random Number Generators & Number Tools.