Format Code Now
/

Random Hex Number Generator

RG-05

Choose how many hex digits each number should have and how many numbers you want, then press Generate. Add a 0x prefix or capital letters if you need them.

Runs in your browser. Nothing is uploaded.

Not used. Press the button to generate.

Hex numbers

How to use it

  1. Choose Hex digits each, for example 8 for a 32-bit value or 32 for a 128-bit value.
  2. Choose How many numbers to make, up to 500.
  3. Tick UPPERCASE or 0x prefix to match the format you need.
  4. Press Generate and copy the list.

Length is counted in digits

Each hex digit holds 4 bits, so 2 digits make one byte, 8 digits make 32 bits and 32 digits make 128 bits. Every digit is drawn on its own from 0 to 9 and a to f with equal chance, so a number can start with zeros and still keeps its full length. That matters for identifiers where leading zeros count.

Text, not a converted number

The output is a string of hex digits. It is not converted to decimal, so very long values are never rounded. Convert it elsewhere if you need the decimal value. The 0x prefix is only added in front of the text and does not change the digits.

Where the digits come from

Digits are picked with crypto.getRandomValues using rejection sampling, so no digit is favored. That suits sample IDs, color codes, test data and nonces. Nothing is stored or sent. For a ready made random byte list or UUIDs, the other random tools on this site are a closer match.

Questions people ask

How do I generate a random hex number?

Choose the number of hex digits, choose how many numbers, and press Generate. Each line is a random hex string of that length, such as 9f3a02bc for 8 digits.

How do I make a random 32 character hex string?

Set Hex digits each to 32 and press Generate. You get 32 hex digits per line, which equals 16 bytes or 128 bits. That is a common length for tokens and identifiers.

Can a random hex number start with zero?

Yes. Each digit is chosen separately, so a leading 0 appears about one time in sixteen. The number keeps its full length, which is what you want for fixed-width IDs.

What is the difference between this and the random byte generator?

This page counts digits and gives one number per line. The byte generator counts bytes, can show them in other bases and can put spaces between bytes. For plain hex strings this page is quicker to set up.

Can I get uppercase hex with a 0x prefix?

Yes. Tick UPPERCASE for A to F and tick 0x prefix to start each number with 0x. Both options only change how the text is written.

How random are these hex numbers?

They come from your browser's cryptographic random generator, with no modulo bias. Anything you copy is not stored anywhere by this page.

About this tool

Each hex digit (0 to 9 and a to f) is drawn separately and uniformly, so numbers can start with 0 and keep their full length. The length is counted in hex digits, not bytes: 2 digits make 1 byte. The numbers are shown as text; they are not converted to decimal. They come from crypto.getRandomValues. Nothing is stored or sent.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.