Skip to main content
June 6, 2026

Free API Key Generator: Which Format Should You Actually Use?

A developer's guide to generating random API keys for free — hex, alphanumeric, Stripe-style prefixed, and segmented formats, and when each one is the right call.

apidevelopersecuritytokens

Format Is a Design Decision, Not a Detail

Most developers grab the first random string they see and move on, but the shape of an API key quietly affects security, debuggability, and how often someone ships a test key to production. A free API key generator lets you try the common formats side by side before you commit a convention to your codebase.

The four formats worth knowing: 64-character hex encodes 256 bits, the same size as a SHA-256 output, which makes it a natural fit when the key doubles as an HMAC-SHA256 secret. 32-character alphanumeric is shorter and easier to read or copy by hand. Stripe-style prefixed keys encode environment and scope in the token itself. Segmented keys split the random part with dashes so it is easier to read and share.

Why Prefixes Pay for Themselves

Stripe's sk_live_ and sk_test_ prefixes are the best-known example, and they exist for a reason: when the key itself announces "this is a live secret key," a developer is far less likely to paste a test token into production or vice versa. A short prefix such as myapp_prod_ or api_v2_ costs nothing and turns an opaque blob into something a human can sanity-check at a glance.

Prefixes also make secret-scanning tools more effective. When GitHub added prefixes such as ghp_ to its own tokens, a key goal was letting secret scanning recognize them with far fewer false positives. Scanners that search repositories for leaked credentials match on recognizable patterns, so a distinctive, consistent prefix makes a leaked key more likely to be caught.

Generated Keys vs. Production Keys

A browser-based generator is perfect for development, testing, seeding databases, writing documentation, and filling config files with correctly shaped placeholders. It is the fastest way to get well-formed tokens without writing a throwaway script. Be aware that this site's API key generators build their keys with JavaScript's Math.random(), which is not cryptographically secure, so treat their output as test data only. The token ID generator draws from the browser's cryptographic random source instead, but real production keys still belong on the server.

For the keys that actually protect production, generate server-side with a cryptographically secure source — Node's crypto.randomBytes, Python's secrets.token_hex, or your platform's equivalent — and store only a hash (our guide to what hashing is for explains why). Use the online tool to lock in your format and naming, then wire the same shape into your server-side issuer.

How Long Should an API Key Be?

As long as the key comes from a cryptographically secure source, length is the main driver of how hard it is to guess. A common rule of thumb is at least 128 bits of entropy — that maps to a 32-character hex string or roughly 22 or more characters of base62 (letters and digits). A 64-character hex key (256 bits) is comfortably beyond any brute-force concern and is a common default for secrets.

Avoid the temptation to make keys short for convenience. Unlike a password a human types, an API key is copied and pasted, so there is little cost to extra length and real benefit to it. If a prefix is added for readability, count only the random portion toward your entropy budget.

Rotating and Revoking Keys

A key is not a set-and-forget secret. Plan for rotation — issuing a new key and retiring the old one — from the start, because keys leak: into logs, repos, screenshots, and old config. Supporting multiple active keys per account makes rotation painless, letting you roll a new one in before disabling the old.

Just as important is fast revocation. If a key is exposed, you need to kill it immediately, which means storing keys server-side (as hashes) so a single delete cuts off access. Distinctive prefixes help here too: through GitHub's secret scanning partner program, a leaked key that matches a provider's registered pattern is reported to that provider, which can revoke it before it is abused. For a broader look at identifier formats, see UUIDs, NanoIDs, and tokens explained.

Frequently asked questions

Is it safe to use a free online API key generator?
For development, testing, seeding, and documentation, yes. This site's API key generators run in your browser but use Math.random(), which is not cryptographically secure, so never use their output as real credentials. For keys that secure production traffic, generate them server-side with a CSPRNG and store only a hash.
What format should I use for a REST API key?
32-character alphanumeric is a readable default. Choose 64-character hex if you need HMAC compatibility, and add a short prefix like myapp_prod_ to encode environment and make leaks easier to catch.
What does the sk_live prefix mean?
It is a Stripe convention where sk means secret key and live means the production environment. Prefixes let developers and secret-scanning tools identify a key's type and scope instantly, reducing the chance of using a test key in production.
How should I store API keys securely?
Store only a hash of the key server-side, never the raw value, so a database leak does not expose working keys — the same principle as password storage. Show the full key to the user once at creation, then only a masked preview.
What is the difference between an API key and a token?
An API key is typically a long-lived secret identifying an application or account. A token (like a JWT or OAuth access token) is usually short-lived, scoped, and issued after authentication. Keys suit service-to-service access; tokens suit user sessions and delegated access.

Sources

  1. Authentication — Stripe Docs
  2. Behind GitHub's new authentication token formats — The GitHub Blog
  3. About secret scanning for partners — GitHub Docs
  4. Insecure randomness — CodeQL documentation (GitHub)