Random Hex Generator
Generate random hexadecimal strings for keys, tokens, session identifiers, test vectors or colour values. Each hex digit carries exactly four bits, so the tool shows the bit length as you change the character count, with presets for the sizes that come up most: 32 characters for 128 bits, 40 for a SHA-1 length, 64 for 256 bits. Values come from the browser cryptographic random number generator. Everything is generated in your browser; nothing is uploaded and no result is recorded anywhere.
How it works
Each hex digit carries exactly four bits, so a 32-character string is a 128-bit value — the usual size for a session token or an API key.
Generated from the browser’s cryptographic random number generator, so the output is suitable for keys and identifiers rather than only for filler.
Values are generated in your browser and never sent anywhere.
16 hex characters is 64 bits.
Adjust the settings above and values appear here.
Frequently asked questions
How many hex characters do I need for a 256-bit value?
Sixty-four. Each hex digit encodes exactly four bits, so the bit length is always the character count multiplied by four — which is why the tool shows both.
Is this suitable for generating an encryption key?
The randomness is cryptographic quality, so the value itself is fine. Whether a key generated in a browser page is appropriate depends on your threat model — for anything that protects real data, generating it inside the system that will use it is the safer habit.
Can I use this for random colours?
Yes — six hex characters is a colour value. Prefix it with a hash and it is ready for CSS, although a purely random colour rarely looks good next to a designed palette.
Why is the output lowercase by default?
Lowercase hex is the more common convention in code, config files and hash output. The uppercase toggle is there for the contexts that prefer it, such as MAC addresses and some protocol specifications.
Is the same string ever generated twice?
At meaningful lengths this is vanishingly unlikely — a 32-character hex string has 2^128 possibilities. At very short lengths repeats become likely quickly, which is worth remembering if you are using them as identifiers.
Related tools
Random String Generator
Generate random strings of any length from the character sets you choose, with a real entropy figure.
Random Byte Generator
Generate random bytes and show them as hex, decimal, binary, Base64, a C array or an escaped string.
UUID Generator
This UUID generator creates RFC 4122-compliant v4 (random) and v7 (time-ordered) UUIDs, one at a time or in bulk, entirely in your browser.