Skip to content
Aarrange

API Key Generator

Make secure API keys with a prefix and a checksum, one or 100,000 at a time. Or paste keys to check them for hidden mistakes. Nothing leaves your browser.

0
Keys
0
Lowest bits
0
Issues
Input
Tab types a tab. Press Escape, then Tab, to leave the editor.
Result

Your new key

Press Generate (Alt G) to put it in the editor, or paste keys there to check them.

On this page

About API Key Generator

Updated

API Key Generator makes keys for your own API, and secrets for your app. Each key has a prefix you pick, a random part from your browser's secure random source, and a 6-character checksum. The key never leaves your browser. Use it as a random key generator for your own API, or as a secret key generator for your app.

It also checks keys. Paste keys or a .env file, and each key gets its strength, its checksum and any hidden mistake. In a .env file, only names with words such as KEY, SECRET or TOKEN are checked. Want plain strings or codes, 10 at a time? Use the Random String Generator. For a JWT secret or a framework key with no prefix, use the Secret Key Generator.

How to generate an API key

  1. Set Count, Format and Length next to Generate. On a phone they are under More.
  2. In Options, set the Prefix (for example myapp_live_) and the Checksum.
  3. Press Generate (Alt G), and copy the key. The Result shows a fresh one before you press anything.
  4. To check keys, paste them one per line. Results shows each key with its strength and checksum, and Notes lists what is wrong.
  5. Open Code to make the same keys in your server: the code adds the prefix and the checksum too.

What a good API key looks like

API key
  • Random part: 128 bits or more from a secure source. Letters and digits copy cleanly: no +, / or = to break a URL or a header.
  • Prefix: short, yours, and ending in _. Use two, such as live_ and test_, so a test key never works in production.
  • Checksum: lets your server and secret scanners turn away a typo or a fake without a database look-up.

Common errors

A space at the end

A key copied from a dashboard or a terminal often brings a space or a line break with it. The request then fails with 401 and the key looks right.

Invalid
Authorization: Bearer api_cJskcKpWo55mI2kQCAbDFda7jYTSCs8u1frW3r␣

Tool:A space at the end. A key with a space in it fails in a header or a .env file. Delete it.

Fixed
Authorization: Bearer api_cJskcKpWo55mI2kQCAbDFda7jYTSCs8u1frW3r

A wrong character in a GitHub token

GitHub tokens end in a checksum. When one character is wrong, the checksum no longer fits, and the tool says so before GitHub turns the token away.

Invalid
ghp_Rk7Qm2Xv9TqW4nHc8LsP3dJf6yGa1Z194COL

Tool:The checksum is wrong. A GitHub token ends in 6 characters made from the rest. A character is wrong or missing: copy the token again from where it was made.

A key that is too short

A short key can be guessed. The tool warns when a key has under 128 bits and has a secret name, such as API_KEY=, or a prefix with a correct checksum.

Invalid
API_KEY=8f3a91c2d4e5

Tool:48 bits. A key needs 128 or more.

Fixed
API_KEY=key_RfW2NdRZsqtpFHUzc1AKik5KfVRh4Q6i

API key resources

API key FAQ

What is an API key?

A long random string that a program sends with each request to an API, often in a header such as Authorization: Bearer. The server looks the key up to see which account or app sent the request, and what it may do. Anyone who has the key can act as its owner, so treat it like a password.

How do I generate an API key?

For your own API: press Generate on this page. The start setting makes a key such as api_ plus 32 letters and digits plus a 6-character checksum: 190 random bits. Set the length and the format next to Generate (under More on a phone), and a prefix in Options.

In code, take random bytes from a secure source: crypto.randomBytes(32) in Node.js, secrets.token_urlsafe(32) in Python, random_bytes(32) in PHP. The Code view shows nine languages.

For a key to someone else's API (OpenAI, Google, Stripe), sign in to that service and make the key in its dashboard. Only the service can make a key that it accepts.

How do I get an OpenAI, Gemini or Google API key?

Make it in the vendor's console. This tool cannot make a key that works there: only the vendor can, because its servers must know the key. A key made here has the right look and none of the access.

OpenAI: sign in and open API keys. Gemini: open Google AI Studio and press Create API key. Other Google APIs: open Credentials in the Google Cloud console. Paste the key here afterwards to check it for a hidden space before you put it in your .env file.

How long should an API key be?

128 random bits or more. That is 22 letters and digits, 32 hex digits or 16 bytes. Most services use 32 characters or more (190 bits), and the start setting here does the same. The prefix and the checksum do not add to the strength: they are not random.

Why do API keys have a prefix?

A prefix says what the key is at a glance: sk_live_ and sk_test_ at Stripe, ghp_ at GitHub. People and logs can tell a live key from a test key, and secret scanners can find a key in code with few false alarms.

Pick your own, short and unique to your product. Do not copy a real vendor's prefix: a made-up sk_live_ key sets off Stripe alarms in scanners.

What is the checksum at the end of a key?

Six characters made from the rest of the key with CRC-32 and written in base62, the scheme GitHub uses for its tokens. It is not secret and adds no strength. It lets a scanner, or your own server, see that a string is a real key before it looks it up, so a typo or a random match is turned away at once. Paste keys in the editor and the tool checks each checksum.

How should I store API keys?

On the server, store a hash of each key, not the key itself, as you would a password. SHA-256 is enough for a random key of 128 bits or more. Show the key to its owner once, when it is made.

Keep keys out of code and out of Git: put them in environment variables or a secret manager. Revoke a key and make a new one when it may have leaked.

What is the difference between an API key and a JWT?

An API key is a random string: the server looks it up to see who it belongs to. A JWT carries its own data (who, what, until when) and a signature, so a server can check it without a look-up. A JWT is signed with a secret key; pick JWT secret (HS256) in Format to make one. To read a JWT, use the JWT Decoder.

Are my keys sent anywhere?

No. The tool makes and checks keys in your browser, with the Web Crypto API. Nothing is uploaded and nothing is logged. Some API key sites make the key on their server and send your settings to an analytics service; this one does not. You can check this in your browser's network tab.