Where the randomness comes from
Every value on this page is built from crypto.getRandomValues(), the browser's cryptographically secure random number generator, seeded by the operating system. It is the same source password managers and TLS use. Math.random() is never involved: it is fast and fine for games, but its output can be predicted and it must never be used for secrets.
Nothing you generate leaves your device. There is no server call, no logging and no analytics on the values, and the page only saves your settings (length, character sets) in the address bar so you can bookmark a configuration. The values themselves are never put in the URL.
Avoiding modulo bias
The naive way to pick a random character is bytes[i] % alphabet.length. With a 62 character alphabet and a random byte (0 to 255), the first 8 characters come up slightly more often, because 256 is not a multiple of 62. This tool uses rejection sampling instead: it draws a 32-bit number, throws it away if it falls in the uneven tail, and only then takes the remainder. Every character is exactly equally likely.
function randInt(n) {
const limit = Math.floor(2 ** 32 / n) * n;
const buf = new Uint32Array(1);
do crypto.getRandomValues(buf); while (buf[0] >= limit);
return buf[0] % n;
}
Reading the entropy number
Entropy is length × log2(alphabet size) for random strings, and words × log2(list size) for passphrases. It assumes the attacker knows exactly how the value was made, which is the honest way to measure. Rough guidance:
- Under 50 bits: weak for anything that can be attacked offline.
- 60 to 80 bits: a strong user password, provided the site stores it with bcrypt, scrypt or Argon2.
- 128 bits and up: API keys, session tokens, password reset links and anything a machine checks millions of times per second.
- 256 bits: HMAC signing secrets for JWTs (HS256) and encryption keys.
Picking the right mode
Password is for accounts that live in a password manager. Go long (20 or more) and let the manager remember it. Passphrase is for the few secrets you must type or remember, like the manager's master password or a disk encryption key. API key mimics the prefixed format popularized by Stripe, which makes keys greppable and lets secret scanners on GitHub catch leaks. UUID v4 gives 122 random bits, ideal for public identifiers, but do not treat a UUID as a secret token by itself unless your threat model is relaxed. Secret bytes matches what you would get from openssl rand -hex 32 or openssl rand -base64 32.
# .env JWT_SECRET=6f1c...e9a2 # 32 bytes, hex encoded SESSION_SECRET=Q2x... # 32 bytes, base64
What is an auth key?
"Auth key" is used loosely for any random secret that proves identity or signs data. Depending on the job it means one of these, and each has a matching mode above:
| You need | Use this mode | Suggested size |
|---|---|---|
| An API key or access token for your own service | API key | 32 or more random characters, with a prefix such as sk_live_ |
| A JWT or session signing secret (HS256) | Secret bytes, Base64url | 32 bytes (256 bits) or more |
| A webhook signing secret or encryption key | Secret bytes, hex | 32 bytes for AES-256 |
| A database or admin password | Password | 20 or more characters |
| A unique identifier (not a secret) | UUID v4 | Standard 36 characters |
| A two-factor (TOTP) key for an authenticator app | Use the Auth Key (TOTP) Generator | 160 bits, Base32 |
How long should a key be?
Strength is measured in bits of entropy, not characters. A key chosen uniformly at random from 62 letters and digits gives about 5.95 bits per character, so 32 characters is roughly 190 bits and 43 characters reaches 256 bits. The generator shows the figure for each result. For signing keys, match the algorithm: RFC 7518 says an HS256 key must be at least 256 bits long, and HS512 at least 512 bits. For anything that is only guessed online, such as a login, a long password plus rate limiting is enough; for anything an attacker can test offline, such as a hashed database or a signed token, use 256 bits.
Handling keys safely after you generate them
- Never commit them to a repository. Put them in environment variables or a secrets manager, and add the variable name to your
.env.examplewithout the value. - Use a different key for each environment and each purpose, so a leak in staging does not expose production.
- Prefixes help. A recognisable prefix lets secret scanners find leaked keys, and it adds no strength.
- Hand keys over with a one-time link, not a chat message. Use Secret Share Links and read the password share links guide.
- Rotate on a schedule and immediately after anyone with access leaves. The JWT Decoder helps you inspect tokens signed with the old key.
Frequently asked questions
Are the generated passwords sent or stored anywhere?
No. Everything is generated in your browser with crypto.getRandomValues. Nothing is sent to a server, logged or saved, and generated values are never written into the page URL.
How many bits of entropy do I need?
For a password protected by a slow hash, 60 to 80 bits is strong. For API keys, signing secrets and anything that could be attacked offline at high speed, use at least 128 bits, and 256 bits for JWT HMAC secrets.
Is a passphrase as secure as a random password?
It can be. Each word from this 495 word list adds about 8.95 bits, so six words give roughly 54 bits and eight give about 72. Longer passphrases are easier to type and remember than random strings of the same strength.
What length should a JWT secret be?
For HS256, use at least 32 random bytes (256 bits). For HS512, use 64 bytes. Encode it as hex or Base64 and store it in an environment variable, never in source control.
What is an auth key generator?
It creates random secrets used to authenticate or sign data, such as API keys, JWT signing secrets, webhook secrets and passwords. This one uses the browser cryptographic random generator and reports the entropy of each result, and the separate Auth Key (TOTP) Generator makes two-factor authenticator keys.
How long should a JWT signing secret be?
For HS256, use at least 256 bits, which is 32 random bytes, as required by RFC 7518. Generate 32 bytes in the Secret bytes mode and encode them as hex or Base64url.