Free · runs in your browser

API Key Generator

API Key Generator. Choose a prefix style and click Generate to build a realistic API key with a cryptographically random suffix. Collision probability stays negligible in the uuid generator, so values work as a unique key in a distributed database.

Your values

Generate 1 to 500 keys at once.

Alphanumeric or Base64url are the safest choices for URLs and headers.

Random characters after the prefix. 32 or more is recommended for production.

Adds a separate secret to each key: the key identifies the client, the secret proves it.

Example key configuration

Builds a sample config for the first key. Scopes are enforced by your server, not by the key.

Result

Generated API key
—
Secret for this key
—
All generated keys (copy)
—
Entropy per key
—
Random characters
—
Keys generated
—
Example key configuration
—
  • No account, no logging
  • Open formulas explained below
  • Works offline once loaded

Need a credential you can paste into a project in seconds? This free online API key generator builds secure API keys from random bytes, so you pick a length, format and prefix, then copy the result into your API token config.

What Is an API Key Generator?

A generator like this produces a long, unpredictable string that identifies a client to a server. Applications treat that string as proof of authentication, and whoever presents it receives the access control attached to it. Your API credentials should come from random bytes, never from a name, a date or a password you remember: a guessable value turns security into a formality, and a secure one is exactly what developers rely on a generator for. Every API call carries the key in a header, so the API can match each request to its owner and apply that owner's limits. Deployment pipelines for a Python backend can take the django secret key generator output and store it in a vault or orchestrator secret to keep it out of the git repository.

How to Generate API Keys in Four Steps

The generator works client-side in your browser, so nothing is sent anywhere. Work through the settings below, click Generate, then copy the result. Need many at once? Bulk generate up to 25 keys and export them as a file. For an Express or Flask service, the jwt secret generator gives a signing secret that cannot be guessed, and the browser never uploads it, which helps authentication.

Set the Key Length

Length drives strength. A 32-character key suits most production use, while 16 is fine for development and quick testing. Every extra character adds bits of entropy, and the table in the next section shows the numbers. Resist trimming a key for convenience, and keep the same length across every environment so your validation rules stay simple and a typo is easy to spot.

Pick the Key Format

Choose alphanumeric for the widest compatibility, hexadecimal for compact output, Base64 for density, or Base64 URL-safe when keys travel in URLs. UUID v4 gives a standard 128-bit layout, and numeric output suits PINs only. A 62-symbol character set is also called base62.

Add a Custom Prefix

A custom prefix such as sk_live marks what a key is for. Code hosts run secret scanning that flags a leaked key with a known prefix, and the issuer can have it revoked before damage spreads. Give every test environment key its own marker; the prefix itself adds no entropy.

Use Key-Secret Pairs for Signing

Switch on key-secret pairs to get a public key (the client ID) you can log safely, plus a private half used for HMAC signatures that prove authorization to act. Never log the private half, and never send it to a public client or a third party.

Generate Secure API Keys: Entropy Explained

Strength is measured in entropy, the number of equally likely outcomes expressed in bits. For a key of length \(L\) drawn from a pool of \(N\) symbols: Upgrading an old Ruby application that warns about missing secrets is simpler with the free rails secret key base generator, which supplies a fresh value for the initializer and encryption.

$$\text{bits} = L \times \log_2 N$$

A 40-character key from the 62-symbol pool carries \(40 \times 5.954 = 238.2\) bits, far beyond any brute force attempt. That only holds if the source is truly random: use a cryptographically secure CSPRNG that follows NIST guidance, never a pseudorandom seeded shortcut, because unpredictability matters more than a tidy-looking string in security-critical systems. A weak source makes brute-force search practical at any length. At 32 characters, the formats compare like this:

Generate Secure API Keys: Entropy Explained
FormatSymbolsBits per characterEntropy at 32 characters
Alphanumeric625.95190.5
Hexadecimal164.00128.0
Base64646.00192.0
Numeric103.32106.3

Security reviewers rarely accept less than 128 bits for an API key that guards customer data, and an API handling payments deserves 190 bits or more. A longer key costs nothing extra to generate, so there is little reason to stop short.

API Token Formats by Platform

Each vendor follows its own key shape, so the leading characters and length tell you where a value belongs.

API Token Formats by Platform
ServiceKey shapeTypical use
Stripesk_live_…Payments
GitHubghp_…Repository access
OpenAIsk-…Model access
AWSAKIA…Cloud services
SendGridSG.…Email delivery

Your own API service can echo that idea by naming the product in the leading characters of each API key, which makes any stray API key easy to trace back to its owner.

API Credentials Compared: Keys, OAuth and JWT

A key is the simplest option: one static value per client, ideal for a REST API or service-to-service calls between a microservice and its peers. OAuth adds delegated scopes and expiring grants for user-facing authentication, while a JWT carries signed claims. A GraphQL endpoint usually needs finer rules than one key per resource, and a bearer token header works with all of them. Webhook secrets follow the same idea, letting a receiver verify the sender.

Permissions and Rate Limiting Presets

Scope each key with permissions such as read-only or write, and enforce least privilege. A permissions builder can pair them with a rate limit of 1,000 requests per hour and an API version tag, so no key reaches further than its job requires.

Secret Key Best Practices for Developers

A secret key is only as safe as where you keep it, so treat it like a password and keep it secure with these best practices:

  • Avoid hardcoding values in a repository, where exposure is permanent.
  • Send keys only over HTTPS.
  • Keep secrets out of browser bundles, which anyone can read.
  • Log key usage for compliance reviews, never the key values themselves.
  • Store production keys in a cloud secrets manager.

Key Rotation and Expiration Schedules

Plan key rotation every 90 days by generating a fresh value in the generator, and sooner after a team change. Set an expiration date so a forgotten key stops working on its own, and keep the old and new values valid briefly so deployments don't fail.

API Tokens in Code: Headers and Environments

Once generated, your application reads the key and attaches it to every call. In an integration with another system, send it in a header such as Authorization: Bearer YOUR_KEY, which the receiving server checks for authentication. Use separate keys for staging and production, a sandbox key for demos, and a CI/CD secret store instead of a script. A key printed in logs defeats the rest, so mask it in every API log line.

Store Keys in Environment Variables

Load the value from environment variables instead of source files: put API_KEY=... in a local .env file, exclude that file from version control and read it at startup.

Using the API Key Generator Tool for a Webhook Receiver

Last week a partner's billing system needed to post invoices to a small receiver I run, so the only decision was how long the key should be. In the generator I entered a length of 36, the alphanumeric format and the label whk_live, and it returned one line: whk_live_ followed by 36 symbols.

The number I care about is the entropy: \(36 \times 5.954 = \mathbf{214.4}\) bits. NIST recommends 128 bits of strength for anything expected to outlast 2030, so this clears the bar by about 86 bits. I cross-checked the arithmetic with math.log2(62) in a Python shell, then reran the tool with other settings:

Using the API Key Generator Tool for a Webhook Receiver
SettingEntropy (bits)Against 128 bits
36 characters, 62 symbols214.4Clears
24 characters, 62 symbols142.9Clears
21 characters, 62 symbols125.0Short
36 characters, 16 symbols144.0Clears

My judgement: length is the input to watch, and 22 characters is the shortest 62-symbol key that reaches 128 bits (131.0). The trap I nearly fell into was a 36-character value that looked just as long but used 16 symbols, which is only 144 bits, and a UUID v4 holds just 122 random bits, so it falls below the line however good it looks. Do not trust a long-looking string without checking its symbol pool.

The next step is concrete: I pasted the key into the sender's field for webhook secrets, signed test payloads with HMAC, kept the value in my .env file, and put a reminder on my calendar to replace it in 90 days.

Frequently Asked Questions

Does the prefix add any real security?
No -- the prefix is purely cosmetic and organizational (it lets you and automated scanners like GitHub's secret scanning instantly identify what kind of key a string is at a glance). All of the actual unguessability comes from the random suffix; a recognizable prefix doesn't weaken a key's security, since the prefix itself is never secret.
Why do real services like Stripe use prefixes like sk_live_?
It lets both humans and automated tooling identify a leaked credential's type and severity instantly -- sk_live_ signals a live secret key needing immediate rotation, while pk_live_ signals a publishable key that's safe to expose client-side by design. Following the same convention in your own API makes leaked-key triage much faster.
How long should the random part be?
32 characters (the default) from a 62-character alphanumeric set gives roughly 190 bits of entropy, far more than needed to resist brute-forcing. Go shorter (16-20) only if your system has a strict length constraint; there's little benefit to going much longer.
Can I use this as a real production API key?
The key itself is generated with genuine cryptographic randomness and is suitable for production use, but you're responsible for hashing it before storing it server-side (never store API keys in plaintext, the same way you'd never store a password in plaintext) and for building proper revocation and rotation support around it.
Is the generated key sent anywhere?
No. It's generated entirely in your browser using the Web Crypto API's cryptographically secure random number generator -- nothing is transmitted, logged, or stored.

About the author

Vinitha Pu

Founder and designer

Vinitha Pu is a graphic designer based in Palakkad, Kerala, who builds free, privacy-friendly browser tools. She studied Textile and Apparel Design at Avinashilingam University and completed a C-Tech in Graphic Design at Image Creative Education in 2025. She designs, builds and maintains the password generators, strength checkers, hash tools and security calculators on PasswordHive.

  • Content author: Vinitha Pu
  • Fact checked by: Vinitha Pu. Each tool's output is checked against official test vectors or a reference implementation, and every strength and crack-time figure against the formula it uses, before it goes live.
  • Published Updated