API key generator

Make random API keys with 256 bits of randomness and a prefix that says what the key is for. They are made in your browser, and nothing is sent anywhere.

runs in your browser · nothing uploaded

loading tool…

How to use it

  1. Pick the strength. 256 bits is the default and is plenty for any API key.
  2. Pick the encoding: base62 (letters and digits only) is the easiest to copy and paste.
  3. Set a prefix, or clear it. Then choose how many keys you need.
  4. Copy one key, copy them all, or download them as a text file.

What makes a good API key

An API key is a password for a program, so it needs to be long and random rather than clever. 128 bits of randomness already can't be guessed; 256 bits leaves a wide margin. A base62 key of 43 characters carries about 256 bits.

A prefix such as sk_live_ or myapp_test_ does not add security, but it helps people. It tells a reader which service and environment a key belongs to. Secret scanners, including GitHub's, use known prefixes to spot leaked keys in code.

How to store API keys on your server

Treat a key like a password: show it to the user once, then store only a hash of it. Because a 256-bit key is random, a fast hash such as SHA-256 is enough here; the slow password hashes (bcrypt, Argon2) exist to protect guessable human passwords.

Keep a short, non-secret ID alongside each key so you can look it up and let users revoke one key without breaking the others.

Generate one in a terminal

openssl rand -hex 32 prints a 256-bit key in hex. In Node.js, crypto.randomBytes(32).toString('base64url') does the same. In Python, secrets.token_urlsafe(32). We ran all three; the output is in the examples folder linked from the guide.

Questions

Is the value sent to a server?

No. It is made in your browser with JavaScript and the Web Crypto API. Nothing is uploaded, logged or stored by us. For production secrets you may still prefer to generate them on the machine that uses them; the command for that is on this page.

How random is it?

Every value comes from crypto.getRandomValues, the browser's cryptographically secure random generator, which is seeded by the operating system. Characters are picked with rejection sampling, so none is more likely than another.

Is an API key the same as a bearer token?

A bearer token is any token that grants access to whoever holds it, sent as "Authorization: Bearer <token>". A long-lived API key is often sent that way. A random string from this page works as either; OAuth access tokens, in contrast, are issued by an authorisation server.

Should I use a UUID as an API key?

No. A UUID v4 has only 122 random bits and a fixed, recognisable format, and other versions are partly predictable. Use a key made for the job, like the ones here.