API Key Generator
Updated Free mock REST & WebSocket APIs
Create random API keys, client secrets, webhook signing secrets and session tokens. Pick a format — prefixed base62 like modern SaaS keys, 32-byte hex or Base64URL — and copy.
🔒 Generated in your browser with crypto.getRandomValues — keys are never sent or stored.
How to generate an API key
- Choose a format, or Custom to set your own length, alphabet and prefix.
- Check the bits of randomness — 128 or more for anything that grants access.
- Copy the key into your secret manager or .env file. Generate several at once for multiple environments.
Designing API keys
- Enough entropy. 128 bits makes guessing impossible; 32 random base62 characters give ~190 bits, 32 bytes of hex give 256.
- A recognizable prefix such as
mf_orsk_test_tells humans what a key is and lets GitHub secret scanning and similar tools spot leaks. - Store a hash, not the key. Save SHA-256(key) in your database and compare hashes on each request; show the full key to the user once.
- Make keys revocable and scoped, and record a last-used time so stale keys can be cleaned up.
- Compare in constant time (e.g.
crypto.timingSafeEqual) to avoid timing leaks.
Generating keys in code
// Node.js
import { randomBytes } from "node:crypto";
const key = "mf_" + randomBytes(32).toString("base64url");
# Python
import secrets
key = "mf_" + secrets.token_urlsafe(32)
# Shell
openssl rand -hex 32Related tools
Embed this tool on your site
Browse all embeddable tools →Free for blogs, HR, payroll and contractor sites: copy one snippet — the widget sizes itself and matches your colors.
Get the embed code
Frequently asked questions
Is it safe to generate production keys here?
Keys are generated locally with crypto.getRandomValues and never leave your device. For fully automated systems, generate keys server-side with the code snippets above instead of copying them by hand.
Hex or Base64URL?
Both are fine. Base64URL is shorter for the same entropy (43 characters for 32 bytes vs. 64 in hex); hex is easier to handle in tools that dislike - and _.
How is an API key different from a UUID?
A v4 UUID has 122 random bits and a fixed format — fine as an identifier but not ideal as a secret. API keys are usually longer, prefixed and meant to be kept private.
Is anything sent to a server?
No. Everything is generated by JavaScript in your browser, so nothing you type or generate is uploaded, logged or stored. It keeps working offline once the page has loaded.
Your business here? Sponsor this tool from $16/week. See placements