FormatterHQ

Random Hex Generator

Create random hexadecimal values of any length, in lowercase or uppercase and with an optional 0x prefix. Great for test IDs, hashes, memory addresses and tokens.

Loading tool…
Ready.

How to use the Random Hex Generator

  1. Enter the number of hex digits per value (1 to 1024).
  2. Choose lowercase or uppercase and whether to add the 0x prefix.
  3. Set how many values you need and whether they must be unique.
  4. Generate and copy the hex values.

Random hex generator for hexadecimal values

Hexadecimal (base 16) uses the digits 0–9 and the letters a–f. One hex digit represents four bits, so two digits make a byte. This random hex generator produces values with an exact number of digits, each chosen uniformly from the 16 possibilities using a secure random source.

Examples

8 digits:            3fa91c07
16 digits, upper:    9B2E04D7C18F5A63
8 digits, 0x prefix: 0x7d0e41b9
6 digits:            c4e2a8   (usable as a color: #c4e2a8)

How long should a hex value be?

Hex digitsBitsLooks like
624A CSS color such as #1e90ff
7–1228–48A short Git commit hash, a MAC address without separators
32128An MD5 digest or a UUID without hyphens
40160A full SHA-1 / Git commit hash
64256A SHA-256 digest or a 256-bit key

Random hex strings of these lengths are ideal as placeholder hashes in documentation, fixtures and UI mockups. Keep in mind they are random, not real digests: if you need the actual hash of some text, use the SHA-256 hash generator.

Uses

  • Fake commit hashes, transaction IDs or checksums for test data and screenshots.
  • Random color codes (use 6 digits and add a #); for a visual palette try the random color generator.
  • Memory addresses and register values in debugging exercises.
  • Tokens and nonces where hex is the expected format.

Options

  • Length – 1 to 1024 hex digits per value.
  • Case – lowercase is the convention for hashes and most APIs; uppercase is common in hardware documentation and Windows tools.
  • 0x prefix – the hex literal syntax in C, JavaScript, Python, Java and many other languages.
  • Unique and separator – avoid duplicates and choose line, comma or space separation.

Reading hex quickly

Each hex digit maps to exactly four bits: 0 = 0000, 8 = 1000, a = 1010 and f = 1111. That is why hex is the preferred way to show binary data compactly: a byte is always two digits, and you can read the bits of any digit without calculation once you know the sixteen patterns.

To turn a hex value into a readable number, use hex to decimal. All values are created in your browser and are never sent to a server.

How many digits avoid duplicates?

Short random values collide sooner than most people expect, because of the birthday problem: the chance of a repeat depends on the number of pairs, not the number of values. As a rough guide, you reach a 50% chance of at least one duplicate after about:

Hex digitsPossible values50% chance of a repeat after
465,536about 300 values
8about 4.3 billionabout 77,000 values
16about 1.8 × 1019about 5 billion values
322128far beyond any real workload

Within one batch, the Unique values option removes repeats for you. Values generated on different days or by different people are not compared with each other, so choose 16 digits or more for IDs that must stay distinct across a whole system.

Frequently asked questions

Is a random hex string the same as a hash?
No. It only looks like one. A hash is computed from input data and is always the same for the same input, whereas these values are random. Use a hash generator if you need a real digest.
Should I use uppercase or lowercase hex?
Both represent the same values. Lowercase is the convention for hashes, UUIDs and most web APIs, while uppercase is common in hardware documentation.
How many hex digits make a 256-bit key?
You need 64 hex digits, because each digit carries 4 bits. The random byte generator can also produce 32 bytes directly in hex.
Can I generate random hex colors here?
Yes. Set the length to 6 and add a # in front of each value. The random color generator additionally shows swatches and RGB or HSL formats.

Last updated October 3, 2026

Related tools