Generate random hexadecimal values of any length, with optional uppercase and 0x prefix. Each hex digit carries exactly four bits, so a 32-digit value is 128 bits β the same shape as an MD5 digest, and 64 digits matches SHA-256.
Settings
Recent results
Generated locally in your browser β your settings and results never leave this page.
Why binary data is written in hex
Computers work in bits, but bits are unreadable in bulk. Hexadecimal is the compromise the industry settled on because the mapping is exact: sixteen is two to the fourth power, so one hex digit is precisely four bits and one byte is precisely two digits. Nothing is rounded, nothing is padded, and converting in either direction is mechanical.
Octal, the earlier convention, groups bits in threes. That worked well on machines with word sizes divisible by three, but it straddles byte boundaries on the eight-bit machines that became universal, which is why hex displaced it almost everywhere outside Unix file permissions.
Where fixed-length hex values show up
A great deal of infrastructure identifies things by hex strings of a known length. Cryptographic digests are the clearest example: an MD5 is always 32 digits, SHA-1 is 40, SHA-256 is 64. Git object identifiers are SHA-1 or SHA-256 digests written in hex. MAC addresses are twelve hex digits. Colour codes in CSS are six or eight.
Generating values of those shapes is genuinely useful when you are building software that handles them. A test that stores digests needs plausible digests. Code that parses an identifier needs values of the right length that are not all the same. The presets exist to produce those shapes without having to remember which length goes with which algorithm.
These are random values, not hashes
A value from this tool has the shape of a digest but is not the digest of anything. That distinction matters if you are testing code that verifies a hash: the value will parse correctly and will fail verification, which is often exactly what you want when checking the error path, but is not a substitute for a real digest when checking the success path.
Reading strength from the length
Four bits per digit makes strength easy to judge. A 32-digit value carries 128 bits, which is the standard floor for a secret that must resist brute force. Sixteen digits carries 64 bits, which is fine as an identifier and not enough as a secret. Eight digits carries 32 bits, which is small enough to enumerate and should only ever be a label.
If you are generating a value that protects something, work from the bit count rather than the visual length. Hex strings look long, and that appearance is not a security property.
Notation conventions
The 0x prefix disambiguates hex from decimal in source code, which matters because a value like 20 is thirty-two in hex and twenty in decimal. Some formats use a leading # instead, as CSS does for colours, and some use none at all because the context is unambiguous. Lowercase is the more common convention in modern codebases, uppercase persists in hardware documentation and in some network tooling.
None of these change the value. They exist so that a reader β or a parser β knows what they are looking at.
Privacy
Values are generated in your browser and never transmitted, stored or logged.
Reading hex by eye
A few habits make hexadecimal quicker to work with. The first digit of a byte is its high nibble, so any value from 80 to ff has its top bit set β useful when checking flags or working out whether a byte would be negative if read as a signed value. A run of ff bytes usually means erased flash or an uninitialised buffer; a run of 00 usually means padding or zeroed memory.
Recognisable byte sequences at the start of a file are worth knowing too. Many formats begin with a fixed signature, which is how file-type detection works without trusting the extension. When you are staring at a hex dump trying to work out what you are holding, the first few bytes are the place to look.
Grouping and alignment
Hex dumps are conventionally shown in groups of 8 or 16 bytes per line because that aligns with the word sizes machines actually use, making offsets easy to calculate in your head. The spaced-hex option here produces the same grouping, which is helpful when comparing a generated value against a dump or reading a value aloud.
How to use the Random Hex Generator
- Set how many hexadecimal digits each value should have. Remember that two digits make one byte.
- Choose how many values to generate.
- Turn on uppercase or the 0x prefix if your target format expects them.
- Generate and copy, or download as text or CSV.
Frequently asked questions
What is hexadecimal and why is it used here?
Hexadecimal is base 16, using the digits 0β9 and the letters aβf. It is the standard way to write binary data as text because each digit represents exactly four bits, so two digits describe one byte precisely with no padding or ambiguity.
How many bits does a hex value carry?
Four bits per digit. An 8-digit value carries 32 bits, 32 digits carry 128 bits, and 64 digits carry 256 bits. The tool reports the figure under each result so you do not have to calculate it.
Why do the presets mention MD5 and SHA-256?
Because those digests have fixed, recognisable lengths β 32 hex digits for MD5, 40 for SHA-1 and 64 for SHA-256. The presets produce values of the same shape, which is useful for testing code that parses or stores digests. They are random values, not real hashes of anything.
Can I use these as colour codes?
A 6-digit hex value is the right shape for a CSS colour, and an 8-digit one includes an alpha channel. For colour work the dedicated random colour generator is a better choice, because it can constrain the result to a usable lightness range instead of producing values that are almost black or almost white.
What does the 0x prefix mean?
It is a convention that marks a number as hexadecimal in source code, used by C, JavaScript, Python and many others. Without it, a value like 100 is ambiguous. The prefix is notation only and adds no information to the value itself.
Does letter case change the value?
No. Hexadecimal is case-insensitive, so ff and FF are the same byte. The option exists because different systems and style guides prefer different spellings, and matching the surrounding convention makes values easier to compare by eye.
Are the digits uniformly distributed?
Yes. Each digit is an independent draw from the sixteen possibilities using rejection sampling, so no digit appears more often than another. Because sixteen divides evenly into the generator's range, this particular case would be unbiased anyway, but the tool uses the same careful method everywhere.