Skip to content

Random Bytes Generator

Get raw random bytes from the browser’s secure generator, formatted the way your code expects.

Processed locally in your browser

Options

What is Random Bytes Generator?

Random bytes are the raw material for keys, nonces, salts, IVs and secrets. They should come from a cryptographically secure generator, never from a general-purpose PRNG. This tool calls crypto.getRandomValues, the same source browsers use for TLS and Web Crypto.

Choose the number of bytes (1 to 1024) and the output format: hex (optionally uppercase), Base64, Base64url without padding or decimal values from 0 to 255. Common sizes: 16 bytes for a 128-bit key or UUID-sized ID, 32 bytes for a 256-bit key, 12 bytes for an AES-GCM nonce, 16 bytes for a PBKDF2 salt.

How does it work?

  1. Set the number of bytes you need (for example 32 for a 256-bit key).
  2. Pick hex, Base64, Base64url or decimal output.
  3. Press Generate and copy. Every click produces new, independent bytes.

Common use cases

  • Creating a 256-bit secret for HMAC signing or JWT HS256 in a development environment.
  • Generating a salt or IV to test an encryption routine.
  • Getting test vectors of a given length for unit tests.
  • Producing an opaque session or CSRF token in Base64url.

Examples

Get raw random bytes from the browser’s secure generator, formatted the way your code expects.

Privacy

Random Bytes Generator runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.

Limitations

Bytes shown on a web page have been visible to your screen and clipboard, so do not use production master secrets generated here. For high-stakes keys, generate them on the machine or HSM that will use them.

Frequently asked questions

How many bytes make a 256-bit key?

32 bytes. In hex that is 64 characters, in Base64 it is 44 characters (with padding).

Is this the same randomness browsers use for TLS?

It is the same Web Crypto API (crypto.getRandomValues), backed by the operating system’s secure random generator.

Why Base64url?

It replaces + and / with - and _ and drops padding, so the value can sit in URLs, cookies and JWTs without escaping.

More tools in Developer Tools →