How to use the random hex generator
- Enter the number of Bytes, from 1 to 1,024 (16 by default). Each byte is two hex characters.
- Choose the Case: lowercase or UPPERCASE.
- Tick Add 0x prefix if the value is going into code as a number.
- Set How many values you need (up to 1,000) and press Generate.
- Copy the list. The stats show the Randomness in bits and the number of Hex characters per value.
What it does and when to use it
Hexadecimal is the usual way to write raw bytes as text. This tool is for any job where you need random bytes in that form: a CSRF token, a password salt, a request or trace ID, a nonce for a test, sample data for a hex viewer, or random 32-bit constants such as 0x9F3A21C0 for a unit test.
Because you set the size in bytes, the strength is easy to read: bytes × 8 = bits. If the bytes are meant to be a cipher key, the encryption key generator offers named AES, ChaCha20 and HMAC sizes plus Base64 output. For random text with letters beyond A–F, use the random string generator. For a random colour as a hex code with RGB and HSL values, try the random color generator.
How it works
For each value the tool asks crypto.getRandomValues for the chosen number of bytes. Each byte (0 to 255) is written as two hex digits, with a leading zero when needed, so 0 becomes 00 and 255 becomes ff. The hex is then upper-cased if you asked, and 0x is added at the front if ticked.
Nothing is hashed or stretched, so all of the bits are random. That is why Randomness is simply the byte count × 8.
Worked examples
- The default 16 bytes. Each value is 32 hex characters, such as
efbad07eb575bbcf588655f721a2ee90, and the stats readRandomness: 128 bits. - A 32-bit constant for code. Bytes 4, UPPERCASE, 0x prefix on. Values look like
0x5BD3980F, and the stats showHex characters: 8. The prefix is not counted. - Over the limit. Asking for 2,000 bytes is capped at 1,024, so the result has
Hex characters: 2,048and 8,192 bits.
Limits and tips
- Values in a batch are independent; the tool does not check them for duplicates. With 4-byte values, the chance of a repeat reaches about one half after roughly 77,000 draws.
- Hex is twice the size of the raw bytes. If space matters, Base64 is shorter for the same randomness.
- Treat any value you use as a secret like a password, and never reuse one across systems.
Frequently asked questions
Why does the tool ask for bytes instead of characters?
Does upper or lower case change the value?
When should I add the 0x prefix?
Is this good enough for security tokens?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.