API Key Generator

Generate prefixed, high-entropy API keys with your browser's cryptographic random source.

  • Runs locally in your browser
  • No upload required

Try it

Produces a deterministic result for documentation and tests. Never use a seeded result as a real secret.

Key 1
sk_test_AFgAnWSB2UiuereAZZI441FaLlBuR3Ot
Key 2
sk_test_XehkTpSv4wX2Uor0lS6mdeimOr9Tv9iq
Alphabet
base64url (64 symbols)
Entropy per key
192 bits
sk_test_AFgAnWSB2UiuereAZZI441FaLlBuR3Ot
sk_test_XehkTpSv4wX2Uor0lS6mdeimOr9Tv9iq

Supported formats

Input
text, number, select
Output
text, number

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

Generated 2 API key(s) with a 32-character secret over the base64url alphabet (192 bits of entropy).

How it works

  • Read the optional prefix, secret length, alphabet and count.
  • Drew each secret character from the platform CSPRNG over the chosen alphabet with rejection sampling.
  • Joined the prefix and the secret with an underscore so the key is recognisable but the secret stays independent.
  • A seed was supplied for a reproducible example; real keys use the platform CSPRNG.
  • Treat a generated key as a secret: paste it straight into a secret manager and never into a URL or a commit.

Methodology

  1. Assemble the alphabet for the chosen encoding.
  2. Draw one character at a time from the platform CSPRNG using rejection sampling, so no character is biased by a modulo shortcut.
  3. Prefix the secret with the caller's label and an underscore when a prefix is present.
  4. Report the alphabet size and the entropy estimate length × log2(alphabetSize).

Usage

  1. Enter an optional prefix such as `sk_live` or `app`.
  2. Choose the secret length and the alphabet (base62, base64url, hex or base32).
  3. Generate the key and copy it directly into your secret manager.

Examples

These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.

Two reproducible base64url keys

jsonSelect to copy
{
  "prefix": "sk_test",
  "length": 32,
  "count": 2,
  "alphabet": "base64url",
  "seed": "example"
}

A 48-character base62 key

jsonSelect to copy
{
  "prefix": "pk",
  "length": 48,
  "alphabet": "base62",
  "seed": "example"
}

A 64-character hex key

jsonSelect to copy
{
  "length": 64,
  "alphabet": "hex",
  "seed": "example"
}

Limitations

A random key is only the beginning

A key generator produces a secret with a known amount of randomness. It cannot scope the key, rotate it or revoke it. Pair it with per-key permissions, an expiry and a rotation policy.

Because the key is a bearer secret, its safety depends on where it is stored. Keep it out of URLs, client bundles and version control; use a secret manager and environment injection.

Frequently asked questions

How much entropy is enough for an API key?
128 bits is the common minimum for a bearer secret. A 32-character base64url secret is about 192 bits, comfortably above that. Use at least that length unless a protocol caps it.
What does the prefix do?
It makes the key recognisable in logs and secret scanners so accidental commits can be detected. It is not a security control on its own.
Is the key transmitted anywhere?
No. Generation is browser-local via `crypto.getRandomValues`, and the page has no network or storage path.

Sources

  1. RFC 4086: Randomness Requirements for Security — IETF
  2. MDN Web Docs — Crypto.getRandomValues() — MDN