Format Code Now
/

Random Byte Generator

RG-02

Choose how many bytes you need and how to show them, then press Generate. Output can be hex, binary, octal, decimal or Base64, from 1 to 256 bytes per line.

Runs in your browser. Nothing is uploaded.

Not used. Press the button to generate.

Random bytes

How to use it

  1. Pick Bytes per line, for example 16 for a 128-bit value or 32 for 256 bits.
  2. Choose Show as: hex, binary, octal, decimal or Base64.
  3. For the number formats, choose what goes between bytes: space, comma, new line or nothing.
  4. Press Generate and copy the result. Use How many to make several lines at once.

What each format looks like

Hex writes 2 digits per byte, binary 8 digits, octal and decimal 3 digits each, padded with leading zeros so every byte has the same width. Base64 encodes the whole line as one string and ends with = padding when the length is not a multiple of 3. The separator choice applies to hex, binary, octal and decimal only.

Where the randomness comes from

Bytes are filled by crypto.getRandomValues, the secure random source built into your browser. That is the same source used by the generators for UUIDs and passwords on this site. The page does not stretch a short seed into a long value, and it does not store or send what it generates, so copy a value right away if you need it.

What it will not do

The page makes bytes, not keys in a specific format. If you need a PEM or JWK key, a salted password hash or a value in a given range, use a tool for that job. Lines are independent sets of bytes, and the page does not remove duplicates between lines, which is only a concern with very short lengths.

Questions people ask

How do I generate random bytes online?

Choose how many bytes per line and the format, then press Generate. A 16 byte hex line is 32 hex digits. The bytes are made in your browser with its secure random generator.

How many bytes do I need for a secret key?

That depends on the algorithm. AES-128 uses 16 bytes, AES-256 uses 32 bytes. Check the documentation for what you are using, then pick the matching length here. This page gives random bytes, not a formatted key file.

What is the difference between hex and Base64 output?

Hex uses 2 characters per byte, so 16 bytes become 32 characters. Base64 packs 3 bytes into 4 characters, so 16 bytes become 24 characters including padding. Both carry the same data, so choose whichever your code expects.

Can I get the bytes as decimal numbers?

Yes. Choose Decimal under Show as and each byte appears as a three digit number from 000 to 255, joined by your chosen separator. Binary and octal work the same way.

Are these bytes truly random?

They come from the browser's cryptographic random generator, which is designed for security uses such as keys. It is not true hardware randomness in every case, but it is the standard source browsers provide for this purpose.

About this tool

Every byte comes from crypto.getRandomValues, the secure random source in your browser. Hex shows 2 digits per byte, binary 8, octal and decimal 3 digits padded with zeros. Base64 ignores the separator option and writes the whole line as one string with = padding. Random bytes are a fine source for keys and tokens, but copy them straight into where you need them: this page does not store anything, so a value you lose cannot be recovered. Lines are separate sets of bytes.

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