Skip to content

Random Hex Generator

Create random hex values of any length, formatted as a key, a nonce, a colour-style code or a byte array.

Processed locally in your browser

Options

What is Random Hex Generator?

Hexadecimal writes each 4-bit nibble as one digit from 0 to 9 and a to f, so one byte is two hex digits. Random hex is the usual way to write keys, salts, nonces, session IDs and test data.

This generator asks the browser’s cryptographic random source for bytes and turns them into hex. You choose the length in bytes or in digits, up to 4,096, and up to 1,000 values at once. You can uppercase them, add a 0x, # or \x prefix, split them into groups of 2, 4, 8 or 16 digits with a separator, and export them as lines or as a JSON array.

How does it work?

  1. Pick the unit (bytes or hex digits) and the length: for example 16 bytes gives 32 digits and 128 bits.
  2. Set how many values you want and whether they should be uppercase.
  3. Choose a prefix and grouping, such as 0x before every 2-digit group to get a C-style byte list.
  4. Click Generate, then copy the values or download them as text or JSON.

Common use cases

  • Making a 32-byte hex secret for an HMAC or a JWT signing key in a development environment.
  • Generating 12-byte hex nonces or IVs for test vectors.
  • Filling fixtures with random tokens or hash-like identifiers.
  • Producing byte arrays such as 0x1f 0xa3 … to paste into firmware or C code.

Examples

Create random hex values of any length, formatted as a key, a nonce, a colour-style code or a byte array.

Privacy

Random Hex Generator runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.

Limitations

A random hex string is only as secret as your handling of it: do not reuse a value you copied from any web page as a production secret without checking your own security requirements.

Frequently asked questions

Is there any bias in the output?

No. Each hex digit maps to exactly 4 random bits, and 16 divides 256 evenly, so every digit from 0 to f is equally likely and no rejection sampling is required.

What happens with an odd number of hex digits?

The tool draws one byte more than needed and drops the last 4 bits, so an odd length such as 7 digits is still uniformly random.

How is this different from the random bytes generator?

Random bytes outputs one value in hex, Base64 or decimal. This tool is built for hex: many values at once, digit-based lengths, prefixes, grouping and separators.

More tools in Developer Tools →