API Key Generator
SecurityGenerate cryptographically secure API keys in hex, base62, or prefixed formats. Choose key length and format. Runs entirely in your browser — nothing stored.
Reviewed by the thecalcu.com team · Last updated July 16, 2026
What is a API Key?
An API Key Generator is a tool that produces cryptographically random secret tokens used to authenticate programmatic requests to an API, service, or system. API keys are how a server verifies that a request comes from an authorised client, they function as machine credentials, similar to passwords, but longer, fully random, and always stored programmatically rather than memorised.
The key quality that matters for an API key is unpredictability: it must be impossible for an attacker to guess the key even if they know the format, the system, or other keys issued by the same service. This tool uses crypto.getRandomValues(), the same cryptographic random source used by TLS key generation and browser-based cryptography libraries, ensuring every key is drawn from a uniform distribution with no exploitable pattern.
Generated keys run entirely in your browser with no server involvement. Nothing you generate is transmitted, logged, or stored anywhere, the value exists only in your browser tab until you copy it and close the page. For a unique identifier that doesn't need to be secret, use the UUID Generator instead. For a human-memorisable credential, the Password Generator is the right tool.
Why Use an API Key Generator?
Developers sometimes generate API keys using weak sources: Math.random(), timestamps, hashes of predictable values, or sequential counters. None of these are appropriate for secrets, Math.random() is not cryptographically secure, timestamps are predictable, and sequential IDs are trivially enumerable. A key generated with true cryptographic randomness is immune to all these attacks.
The prefixed format addresses a different problem: key management hygiene. When all your credentials are random hex strings, it's easy to accidentally use a live production key in a test environment or vice versa. Prefixes like sk_live_, pk_test_, or api_v2_ make the key self-describing at a glance, which is why Stripe, Twilio, and most modern API providers have adopted this convention.
Who Should Use This Generator?
Backend developers building APIs or internal tools use this to generate initial API keys for services, webhooks, or inter-service authentication. DevOps and platform engineers use it to provision secrets for environment variables, Kubernetes secrets, or secret manager entries during infrastructure setup. Security engineers and developers rotating credentials after an accidental exposure use it to generate a fresh replacement key quickly. Indie developers building SaaS products use the prefixed format to establish a professional credential convention from day one, matching the patterns their users are already familiar with from services like Stripe and GitHub.
For credentials that also need to be human-memorable (a shared team secret, a backup code), the Passphrase Generator or Password Generator are better choices.
What Insights Does the API Key Generator Give You?
The Key Format determines the character set and therefore the entropy density per character: hex gives 4 bits per character, base62 gives about 5.95 bits. For the same key length, base62 provides ~49% more entropy than hex, a meaningful difference for short keys, negligible for 32-character or longer keys. The Prefixed format adds a recognisable label before the random body, slightly reducing the random portion but adding operational clarity. The UUID-style format is a fixed 36-character RFC 4122 v4 UUID, useful when system constraints require that format.
Key Length (16–128 characters) controls entropy directly. The default of 32 characters provides 128 bits of hex entropy or ~190 bits of base62 entropy, both well above the threshold of any foreseeable attack.
How to use this API Key calculator
- Select the Key Format, Hex for universal compatibility, Base62 for maximum entropy density, Prefixed if you want a self-describing key, or UUID-style for RFC 4122 compliance.
- If using the Prefixed format, enter your Custom Prefix, for example
sk_live,pk_test, orwebhook_v2. - Set the Key Length, 32 is the recommended default; increase only if your system policy requires it.
- Set Number of Keys to how many you need, up to 10 at once.
- Review the generated keys in the output panel.
- Click the copy icon to copy all keys to your clipboard, then store them immediately in your secret manager,
.envfile, or key vault. Do not leave secrets in your browser history or clipboard longer than necessary.
Formula & Methodology
The generator uses two character pools: - Hex:0123456789abcdef(16 characters, 4 bits per character) - Base62:0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ(62 characters, ~5.95 bits per character) For each character in the key body, a 32-bit cryptographically random integer is drawn fromcrypto.getRandomValues()and reduced modulo the pool size to select a character. This is the same approach used by most production cryptographic key generators. Entropy by format and length: | Length | Hex (bits) | Base62 (bits) | |--------|-----------|---------------| | 16 | 64 | 95 | | 32 | 128 | 190 | | 64 | 256 | 381 | The UUID-style format uses 128 bits of raw random bytes, sets 6 bits to fixed values (version 4 marker and variant bits), leaving 122 bits of actual entropy, formatted as the standard 8-4-4-4-12 hex string with hyphens. The Prefixed format takes a user-supplied alphanumeric prefix (sanitised to remove any special characters), appends an underscore separator, then generates the random body using the base62 pool at the specified length. The prefix itself contributes no entropy, all randomness comes from the body.
Frequently Asked Questions