RandomNr

Random Hex Number Generator

Generate random hexadecimal values of any length, useful for colours, keys, identifiers and test fixtures.

Random Hex Generator

3F9A2C7E

8 digit hex

How many values

Length

How to use the hex generator

  1. Set the number of hex digits.
  2. Add a 0x prefix or switch case to match your code.
  3. Generate one value or a batch, then copy or export.

What is a hex number generator

A hex number generator produces hexadecimal values of any length, useful for colours, keys, identifiers and test fixtures. Set the digit length and how many you want, choose whether to add a 0x prefix or upper case, and Random Nr draws each value from the browser secure random source, ready to drop straight into code or a design tool.

What is each hex length used for

Because two hex digits make one byte, hex length maps cleanly onto common data sizes, which is why certain lengths appear everywhere.

Hex digitsBytesCommon use
21a single byte, a colour channel
63an RGB colour such as 3F9A2C
84a 32 bit value, a short id
3216a 128 bit key or a UUID sized token

The six digit colour is the one most people meet daily: two hex digits each for red, green and blue, so FF0000 is pure red and 000000 is black.

How hexadecimal relates to bytes

A byte holds a value from 0 to 255, and that is exactly the range two hex digits cover, 00 to FF. One hex digit maps to four bits, a nibble, so two of them make a full eight bit byte with no waste. That clean fit is why raw data, memory addresses and colour codes are almost always written in hex rather than decimal, where a byte would need an awkward one to three digits.

What hex numbers are used for

Six hex digits give a web colour, longer strings give keys, tokens and identifiers for test fixtures, and a 0x prefix marks the value as hex in most programming languages. Every digit is drawn from the browser cryptographic source. To read a hex value back as decimal, use the number base converter, or draw the raw bits with the binary generator.

More math and sequence generators

Frequently asked questions

What is hexadecimal

Base 16, using 0 to 9 and A to F. Two hex digits make one byte, which is why hex is common for colours and raw data.

Can I add a 0x prefix

Yes. Tick the option to prefix each value with 0x, the form used in most programming languages.

Can I choose the case

Yes. Switch between upper and lower case letters to match your code style.

Can I make a colour code

Yes. Six hex digits give a colour value such as 3F9A2C, ready to paste into CSS or a design tool.

Is it free

Yes, free and with no sign up.

Related generators

Convert a value to hex with the number base converter, or draw binary or octal.