Generate Random Bytes

Generate random byte sequences in the browser, inspect the output in multiple formats, and use secure browser randomness when it is available.

Generate between 1 and 256 random bytes per run.

Result
16 random bytes

Generated with crypto.getRandomValues() for browser-grade randomness.

Format
hex
Bits Total
128
Random Source
Secure crypto
Output
48 d8 bd 0f 70 39 f5 c4 0f b9 ff ef 04 11 ba 0e

How The Generator Works

The tool allocates a `Uint8Array`, fills it with random values from 0 through 255, and then formats the resulting bytes for display.

When the browser exposes `crypto.getRandomValues()`, that API is used instead of `Math.random()` so the byte stream is suitable for stronger randomness needs.

Quick Examples

Eight random bytes are enough for compact test tokens and binary examples.
Hex output is the easiest way to scan raw byte boundaries at a glance.
Base64 output is useful when the random bytes need to fit in text-based payloads.
Decimal output helps when you want to inspect each byte as an integer from 0 to 255.

Frequently Asked Questions

What is a byte?

A byte is eight bits and can represent an integer value from 0 to 255.

Why show multiple formats?

Different workflows want different views of the same bytes, such as hex for debugging, Base64 for transport, or decimals for inspection.

Is this cryptographically secure?

It is secure when `crypto.getRandomValues()` is available. The tool clearly shows when it had to fall back to `Math.random()` instead.

What can I use random bytes for?

They are useful for demos, fixtures, protocol testing, nonces, and other situations where raw unpredictable data is helpful.

Useful Notes

One byte equals two hexadecimal characters.

Random bytes are the raw building blocks behind many tokens, binary blobs, and encoded identifiers.

Longer byte sequences increase the space of possible outputs very quickly.

Related Tools