API Key Generator

An API key is a bearer credential: whoever holds it can act as the account it belongs to. That makes the way a key is generated genuinely important, and it rules out the tempting shortcuts of a timestamp, a hash of the customer name, or anything produced by a non-cryptographic random function. Predictable keys can be enumerated.

This generator produces long random tokens using your browser's cryptographically secure random number generator, suitable for API keys, webhook signing secrets, service credentials and session identifiers. Longer is better; a key of thirty-two characters or more removes brute force from the realistic threat list entirely.

Generation is only half the job. Store keys hashed rather than in plain text so a database leak does not hand out working credentials, prefix them so they can be recognised and revoked quickly, keep them out of source control and client-side code, and rotate them on a schedule as well as immediately after any suspected exposure.

How to use the API Key Generator

  1. Choose a key length; thirty-two characters or more is a sensible default.
  2. Generate the key or a batch of keys.
  3. Copy the value straight into your secrets manager or environment configuration.
  4. Store only a hash of the key in your database, alongside a recognisable prefix.
  5. Record an owner and a rotation date so the key does not live forever unreviewed.

Examples

Frequently asked questions

How long should an API key be?

Thirty-two characters of random data is a common minimum. Longer costs nothing and removes any brute force concern.

Is the key generated securely?

Yes. It uses the Web Crypto random number generator in your browser, not a predictable pseudo-random function, and nothing is transmitted.

Should keys expire?

Yes. Rotate on a schedule and revoke immediately on suspected exposure. Support two active keys during rotation so the changeover causes no downtime.

Can I use these as passwords?

You can, though a password generator with configurable character sets is usually a better fit for site logins.

SwiftMultiTool — free online tools for everyone. Home · Blog · About · FAQ · Contact