JustGenerator
Security & Keys 100% Client-Side Privacy

Random Token Generator

Create cryptographically secure API keys, JWT secrets, webhook signing secrets, and random tokens using your browser's Web Crypto CSPRNG.

Primary Secure Token ~256 bits entropy

Generating...

Presets:

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.

Common questions

What is the difference between an API key, an API secret, and an access token?

An API key usually identifies which application is making a request (similar to a username). An API secret acts like a password that stays confidential on your server. An access token (such as a short-lived OAuth bearer token or JWT) is issued dynamically to grant temporary permission to specific resources.

How random do API keys and secret tokens need to be?

Security tokens must come from a Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) such as crypto.getRandomValues() in browsers, crypto.randomBytes() in Node.js, or Python secrets. Never use Math.random() for secrets because its internal state is predictable.

What length and encoding format should I choose for a secret token?

A good production baseline is at least 128 to 256 bits of entropy. That equals 32 to 64 hexadecimal characters, or roughly 22 to 43 Base64URL characters. Hex and Base64URL are both safe for environment variables, JSON configs, and HTTP headers without escaping issues.

Should I add prefixes like sk_live_ or whsec_ to API keys?

Yes. Prefixes do not add cryptographic entropy, but they make keys instantly recognizable to engineers and automated secret scanners like GitHub Secret Scanning. Knowing at a glance whether a leaked string is a staging key or a production secret speeds up incident response.

Where should I store generated secret tokens safely?

Never commit secret tokens into Git repositories or client-side frontend bundles. Store them in local .env files excluded via .gitignore during development, and use a dedicated secrets manager such as AWS Secrets Manager, HashiCorp Vault, Doppler, or Cloudflare Worker Secrets in production.

Is it safe to generate secret keys in a web browser?

Yes, provided the generator runs 100% locally using the browser Web Crypto API (crypto.getRandomValues) and never transmits the generated value to any backend server. This tool creates every byte locally inside your browser tab.