Random Key and Bytes Generator

Generate cryptographically secure random keys, salts, tokens and byte arrays in several encodings, using your browser's own secure random source.

Entropy per key

Five of the six formats are the same bytes wearing different clothes

Hexadecimal, Base64, URL-safe Base64, Base32 and the decimal byte array are all reversible encodings: nothing is added and nothing is lost, so running any of them backwards recovers the exact bytes. Pushing all 65,536 two-byte inputs through each one gives 65,536 distinct outputs every time, which is what “reversible” means when you check it rather than assert it. So a 32-byte key holds 256 bits of randomness in every one of them. What changes is how many characters that takes.

FormatCharacters at 32 bytesBits per characterBits carried
Hexadecimal 64 4 256
Base32 52 5 256
Base64 44 6 256
Base64 URL-safe 43 6 256
Letters and digits 32 5.954 190.5

Base64 is the densest of the reversible four, because 6 bits is the most you can pack into a character while staying inside a printable, case-sensitive alphabet with barely any punctuation. URL-safe Base64 comes out one character shorter only because it strips the padding. Base32 gets 5 bits per character rather than 6 because it draws on only 32 symbols: the 26 letters plus the digits 2 to 7. That makes it case-insensitive and leaves out 0, 1, 8 and 9 — the digits most easily misread as O, I, B and g — at the cost of a longer string.

The sixth is not an encoding, and this page used to report it wrongly

“Letters and digits” does something different. It takes each random byte and maps it onto one of 62 characters, discarding bytes of 248 and above so the 62 stay equally likely. That rejection is done correctly — 248 is exactly 4 × 62, so every character is reachable from exactly 4 byte values, and only 8 of the 256 are thrown away. Skipping that step and taking the byte modulo 62 directly would quietly favour the first eight characters. But it discards information on purpose. A byte carries 8 bits; a character out of 62 carries log₂(62) = 5.954. And the output is one character per input byte, so 32 bytes come out as 32 characters holding 190.5 bits rather than 256.

PresetBytesMost formatsLetters and digits
Password salt 16 128 bits 95.3 bits
AES initialisation vector 12 96 bits 71.5 bits
128-bit key 16 128 bits 95.3 bits
256-bit key 32 256 bits 190.5 bits
512-bit key 64 512 bits 381.1 bits
JWT signing secret 64 512 bits 381.1 bits
Session token 32 256 bits 190.5 bits

A shortfall of 25.57%, identical at every size, because it is a fixed ratio of 5.954 to 8. The entropy readout on this page reported bytes × 8 for every format — right 5 times out of 6 and overstating the sixth by a third. It now computes the figure per format, so choosing “Letters and digits” at the 256-bit preset shows 190.5 bits.

None of which makes the output weak. 191 bits is far past anything brute force will ever reach, and the reason to want letters and digits is usually that some other system refuses punctuation. It made the number on the screen wrong, which is a different problem. If you want a true 256 bits out of that alphabet you need 43 characters — the same length URL-safe Base64 reaches from a smaller alphabet, and 22 characters is where it clears 128 bits.

How to use

  1. Choose the length in bytes and the output encoding.
  2. Generate the key.
  3. Copy it straight into your secret store.
  4. Never commit it to version control.

Frequently asked questions

What makes this randomness suitable for keys?

It uses the Web Crypto API's secure random generator, seeded by the operating system's entropy pool and designed to be unpredictable even to someone who has seen previous outputs. Math.random offers none of those properties and must never be used for anything security-related.

How many bytes do I need?

Thirty-two bytes, or 256 bits, is the standard choice for symmetric keys and covers almost every case. Sixteen bytes is adequate for many purposes and is a common size for salts and identifiers. Going beyond 32 rarely adds meaningful security and simply produces longer strings.

Which encoding should I use?

Hexadecimal is unambiguous and easy to read but takes two characters per byte. Base64 is more compact, and its URL-safe variant avoids characters that need escaping in web addresses and file paths. The bytes are identical; only the representation differs.

What is a salt for?

Making identical inputs hash differently. Adding a unique random salt to each password before hashing means two users with the same password get different hashes, which defeats precomputed lookup tables. A salt is not secret and does not need to be — it needs to be unique.

Does the key get transmitted anywhere?

No. Generation is entirely local to your browser, and nothing is sent, logged or stored. Disconnecting from the network and generating a key is a reasonable way to satisfy yourself of that.

Where should I store a generated key?

In a secrets manager, an environment variable loaded at runtime, or your platform's key store — never in source code or a committed configuration file. Keys leaked through version control are a leading cause of breaches, and removing one from git history afterwards is genuinely painful.

🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.