Skip to content

API Key Generator

Generate random API keys and secrets with an optional prefix such as sk_test_. Choose base64url, alphanumeric, base32 or hex, 8 to 96 characters, up to 100 keys.

Generating…

Generating a key in your browser…

Generated in your browser and not sent to our server.

Presets

Presets copy a prefix and length convention. The keys are random strings and will not work with any third-party service.

Character set
32 characters
How many

01 · Definition

What is an API key?

An API key is a long random string that a client sends with each request so a service can identify and authorise it. Its security comes from being unguessable: a key with 128 or more bits of entropy from a cryptographic random source cannot be found by trial. Many services add a fixed prefix so leaked keys are easy to recognise.

02 · Overview

How the API Key Generator works

Generates random keys and secret tokens with crypto.getRandomValues and rejection sampling. Choose a character set (base64url, alphanumeric, base32 or hex), 8 to 96 random characters, an optional prefix such as sk_test_ or whsec_, and 1 to 100 keys. The entropy shown is calculated from the key on screen and does not count the prefix. Presets copy common prefix and length conventions; the keys are random strings and are not valid credentials for any service. Keys are generated in your browser and are not sent to our server.

03 · Guide

How long should an API key be?

Entropy is the number of random characters times the bits each character carries. The prefix is fixed text and adds nothing. 128 bits is a common minimum for a secret key and 256 bits is a common choice for signing secrets; RFC 7518 requires an HS256 key of at least 256 bits.

base32 here is the RFC 4648 alphabet, A to Z and 2 to 7, which leaves out the digits 0, 1, 8 and 9 and survives case-insensitive systems.

Character setCharactersBits per characterFor 128 bitsFor 256 bits
hex1643264
base323252652
alphanumeric625.952243
base64url6462243
Characters needed per character set

04 · Use cases

When to use the API Key Generator

  1. 01

    Create a key format for your own API, with a prefix your team can recognise

  2. 02

    Generate a 256-bit secret for signing webhooks or HS256 JWTs

  3. 03

    Seed a test database with up to 100 distinct keys

  4. 04

    Make a random bearer token for local development

05 · Examples

API Key Generator examples

Prefix sk_test_, base64url, 32 characters

ex 01

sk_test_2HyHHSCJ_Y1BEOnaGz5YD6zRqzqijRaN

The random part has 192 bits. The prefix is a naming convention, not a working key for any provider.

No prefix, hex, 64 characters

ex 02

9ad8ba26d6a4c322f48f7447ec95281d505e46fa53fc89bbc33ad42ab671e893

256 bits, suitable as an HS256 JWT secret or an HMAC key.

Prefix whsec_, hex, 64 characters

ex 03

whsec_1d7a9e02bfbbaf852269928a6c6242808b7761806af37ad861d6321b5a457d5b

A 256-bit webhook signing secret with a recognisable prefix.

No prefix, base32, 26 characters

ex 04

K42PN3AFTAYRCPHKYOR3MD6VGV

130 bits using only A to Z and 2 to 7, for keys that are read aloud or typed.

06 · FAQ

API Key: frequently asked questions

How much entropy does an API key need?

128 bits is a sound minimum and 256 bits costs only a few more characters. That is 22 base64url characters (132 bits), 26 base32 characters (130 bits) or 32 hex characters (128 bits). The tool shows the entropy of the key on screen and updates it when you change the length or character set.

Why use a prefix?

A prefix such as sk_live_ or whsec_ tells a person what a string is when it appears in a log, a config file or a screenshot, and gives secret scanners a pattern to match so a leaked key can be flagged. It adds length but no entropy, so the tool leaves it out of the bit count.

Are these keys safe to use in production?

The random part comes from window.crypto.getRandomValues, the browser's cryptographically secure generator, with rejection sampling so every character is equally likely. The key is generated in your browser and is not sent to our server. Treat it like any secret: copy it straight into your secret store.

Will a preset key work with Stripe or GitHub?

No. The presets copy a prefix and length convention so your own keys look familiar. The result is a random string that no provider has issued, and real provider tokens can include checksums that these do not.

How should I store an API key on the server?

Store a hash of it, not the key. Show the full key to the user once at creation, keep a SHA-256 hash and a short display prefix, and verify incoming keys by hashing them and comparing. A fast hash is appropriate here because the key already has high entropy, unlike a password.

Which character set should I choose?

base64url gives the most entropy per character and is safe in URLs and headers. Alphanumeric avoids the - and _ characters. base32 leaves out 0, 1, 8 and 9 and is case-insensitive. Hex is the longest for the same strength but is accepted everywhere.

07 · Reference

Specs and further reading

These are the primary sources this tool follows. Where a specification defines the behaviour, we link the specification, not a summary of it.

08 · More

Tools that pair with API Key

Last updated .