Secure Opaque Token Generator
Generate high-entropy tokens for sessions and API keys — batch mode, standard Base64, prefix/suffix, and copy as a Bearer header.
What is Opaque Token Generator?
An opaque token is a random string your server uses as a pointer: every request presents it, and the server looks it up in its own store. There is no payload to read, no signature to verify, and nothing sensitive sits on the client — the token stops working the moment its server-side record is deleted.
The generator adds the conveniences you usually bolt on yourself:
sk_live_ or _prod for environment and key-type scoping.Authorization: Bearer <token>.Zero-Server Tool Data Guarantee
All tokens are generated locally in your browser using the Web Crypto API (crypto.getRandomValues). No token data ever leaves your device — generated tokens, prefixes, and suffixes are never transmitted to any server.
How to Use
Set Length and Alphabet
Choose a random-core length (8–256) and an alphabet — URL-safe, standard Base64, Base62, hex, or extended URL-safe.
Configure Batch and Shape
Set the count (1–100) for single or batch output, and add an optional prefix or suffix to scope the tokens.
Generate
Click 'Generate' to create cryptographically secure random tokens using crypto.getRandomValues().
Copy or Export
Copy any token, copy it as an 'Authorization: Bearer <token>' header, or export the whole batch as TXT, CSV, or JSON.
Common Use Cases
Session Identifiers
Generate secure session tokens for httpOnly cookies. Your server maps the token to a user session in Redis or a database.
API Key Provisioning
Batch-generate keys for teams or integrations, scope them with prefixes like sk_live_, and export the set as CSV or JSON for your records.
OAuth 2.0 Bearer Tokens
Issue opaque bearer tokens and validate them with an Authorization header. Revoke instantly by deleting the server-side record.
Password Reset Tokens
Generate one-time-use tokens for password reset flows. The token is stored server-side with a short expiration window.
Environment Scoping
Use prefix/suffix markers to distinguish production, staging, and sandbox keys without decoding the token.
Implementation Examples
// Generate N URL-safe tokens with an optional prefix/suffixconst ALPHABET_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";const ALPHABET_B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function randomByte() {return crypto.getRandomValues(new Uint8Array(1))[0];}function randomToken(length, alphabet = ALPHABET_URL) {const size = alphabet.length;const limit = 256 - (256 % size); // reject bytes that would bias the outputlet out = "";for (let i = 0; i < length; i++) {let b;do { b = randomByte(); } while (b >= limit);out += alphabet[b % size];}return out;}function generateBatch(count, length, { prefix = "", suffix = "", alphabet = ALPHABET_URL } = {}) {return Array.from({ length: count }, () => prefix + randomToken(length, alphabet) + suffix);}const tokens = generateBatch(10, 32, { prefix: "sk_live_" });// tokens: ["sk_live_a3f8c1e2b4d6...", "sk_live_9b0c…", ...]// Send the first token as a Bearer headerfetch("/api/me", { headers: { Authorization: "Bearer " + tokens[0] } });
Opaque Tokens vs JWTs
| Feature | Opaque Token | JWT |
|---|---|---|
| Contains user data | No (lookup key only) | Yes (claims payload) |
| Validation | Database / cache lookup | Cryptographic signature |
| Revocation | Instant (delete record) | Difficult until expiration |
| Token size | Fixed (e.g., 32 bytes) | Grows with claims |
| Server-side storage | Required | Optional (stateless) |
| Best for | Sessions, API keys | Stateless auth, microservices |
Production Best Practices & Security
+ and / characters (and = when padded) require URL-encoding in query strings and paths. Why:a + is decoded as a space in form-encoded URLs and a bare / can break path parsing, so these tokens get mangled in transit; URL-safe alphabets avoid that class of bug entirely.sk_live_ does not strengthen the token. Why:only the random core contributes security; keep the core at least 32 characters even when you add a prefix.Frequently Asked Questions
An opaque token is a randomly generated string your server uses as a pointer: every request presents it, and the server looks it up in its own database or cache. The token is meaningless everywhere else.
Where a JWT carries claims inside itself, an opaque token carries none — who the user is and what they may do lives server-side, keyed by the value.
That is exactly why revocation is so clean: remove the record and the token stops working on the very next request. It is the standard choice for session cookies and OAuth 2.0 bearer tokens.