How much entropy your token actually needs
A token's character count by itself does not tell you how strong it is. Strength depends on the alphabet size multiplied by the length: length × log₂(alphabet) bits. Each hexadecimal character carries 4 bits of entropy, so a 64-character hex string gives you 256 bits. Each Base64URL character carries 6 bits, which is why a 43-character Base64URL string hits roughly 258 bits in two-thirds the space.
The live entropy pill above the primary token recalculates as you drag the length slider or change alphabets. For most backend jobs (JWT HS256 secrets, session cookie keys, OAuth client secrets, webhook HMAC keys), aiming for 256 bits gives you a comfortable margin against brute-force guessing without making environment variables unwieldy.
Why we avoid Math.random() and modulo bias
JavaScript's Math.random() uses a fast non-cryptographic generator (xorshift128+ in V8) whose state can be recovered after observing enough outputs. Every token on this page is built from crypto.getRandomValues(), which reads directly from your operating system's CSPRNG. We also apply rejection sampling so characters at the front of the alphabet are never favored over characters at the end.
Using prefixes and choosing a safe alphabet
Adding a short prefix like sk_live_, pk_test_, or whsec_ does not change entropy, yet it pays off quickly in real repos. Secret scanners on GitHub and GitLab rely on recognizable prefixes to alert you within seconds if someone accidentally commits a key. Prefixes also prevent engineers from pasting a production webhook secret into a staging environment variable.
Watch out for punctuation when picking an alphabet. The High-Density symbol option packs more entropy per character, yet symbols like $, !, and # can trigger variable expansion or comment parsing inside .env files, shell commands, and YAML configs. Stick to Hexadecimal or Base64URL whenever a token will travel through HTTP headers, URLs, or Docker environment blocks.
Storing API keys after you generate them
If you are issuing API keys to your own customers, treat them like passwords on the server side: show the plaintext token once at creation time, store a SHA-256 (or SHA-512) digest in your database, and hash incoming bearer tokens on every request. Unlike human passwords, a 256-bit random token cannot be dictionary-attacked, so a fast SHA-256 lookup is both safe and fast. When you need non-secret database row IDs instead of bearer tokens, switch to our UUID v4 Generator, or use the RSA Key Pair Generator for asymmetric token signing.