API Key Generator

Generates random API keys in hex, UUID or base58 formats, using the browser's cryptographic random source. Suitable for real use — and how you store and transmit the key matters more than how you generated it.

Live demo · real result from this tool
Randomness
A recognisable prefix lets secret scanners spot leaked keys. It adds no randomness.

Press Generate to create a result.

Processed on your device — nothing is uploaded.

How to use API Key Generator

  1. Choose a format — hex is the safe default, base58 for a shorter string.
  2. Set the length; 32 hex characters is 128 bits, 64 is 256.
  3. Generate and copy the key straight into your secrets store.
  4. Store a hash of it server-side, never the key itself.
  5. Generated with crypto.getRandomValues, so suitable for production use.
  6. Base58 omits 0, O, I and l, which makes keys safer to read aloud and retype.
  7. The key exists only in this tab — copy it before navigating away.

How long a key needs to be

128 bits of randomness is the practical floor and 256 bits is comfortable. In hex that is 32 and 64 characters; base58 packs the same entropy into fewer characters, which is why cryptocurrency addresses use it. What matters is the entropy, not the length of the string — a 64-character key built from a predictable pattern is worth nothing, while 32 random hex characters is beyond any brute force.

Prefix your keys, and make them recognisable

Stripe’s sk_live_ and pk_test_ convention has been widely copied because it solves real problems: a developer can tell a secret key from a publishable one at a glance, a live key from a test key, and — crucially — automated secret scanners can recognise the pattern and alert when one is committed to a public repository. GitHub’s secret scanning partners with providers on exactly these prefixes. A bare random string has none of that.

Store a hash, not the key

Treat API keys like passwords: store a hash in your database and show the key to the user exactly once, at creation. If your database leaks, hashed keys are useless to the attacker. Because keys are high-entropy random strings rather than human-chosen passwords, a fast hash such as SHA-256 is adequate here — the dictionary attacks that make bcrypt necessary for passwords do not apply. Store a prefix and a last-four in plaintext so users can identify which key is which.

Rotation, scoping and expiry

Issue keys that can be revoked individually rather than one shared secret, so a compromise is contained and rotation does not break everything at once. Scope them to the minimum permissions needed — a read-only key for a reporting integration cannot be used to delete anything. Set expiry dates, log last-used timestamps so you can spot keys that are no longer needed, and allow two active keys during a rotation so customers can migrate without downtime.

Frequently asked questions

Which format should I use?
Hex is the most universally compatible; UUID is common where keys double as identifiers; base58 avoids visually ambiguous characters (0/O, l/I) in keys users may need to type.
Is this generated securely enough to actually use?
Yes. Generation uses your browser's cryptographically secure random source (Web Crypto API), not a predictable pseudo-random function.
Does this tool send anything to a server?
No. Everything is generated entirely client-side in your browser — nothing you generate is ever transmitted anywhere.
How long should an API key be?
At least 128 bits of entropy — 32 hex characters — and 256 bits is a reasonable default. Beyond that you gain nothing: the entropy is what matters, and no attacker is brute-forcing 128 random bits.
Should I store API keys hashed?
Yes. Hash them like passwords and show the key once at creation. Because keys are high-entropy random strings, a fast hash such as SHA-256 is sufficient — bcrypt's slowness exists to defeat dictionary attacks on human-chosen passwords, which do not apply here.
Is it safe to generate an API key in a browser?
The randomness is sound — crypto.getRandomValues draws from the operating system's entropy pool and is suitable for cryptographic use. The practical caution is the same as for any secret handled outside your own systems: copy it straight into your secrets store, and rotate if you have any doubt about the machine.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close