How to use the bearer token generator
- Set the token length between 8 and 256 characters.
- Pick a character set: hexadecimal, alphanumeric or base64url.
- Click Generate to produce a new random bearer token.
- Copy the raw token or the complete
Authorizationheader from the results.
What is a bearer token?
A bearer token is an opaque string used in HTTP authentication. When a client sends a request to a protected resource, it includes the token in the Authorization header using the Bearer scheme defined in RFC 6750. The server validates the token and grants access without requiring additional credentials.
The word "bearer" means that whoever holds the token can use it. There is no proof of identity beyond possession of the string itself. This makes secure transport over HTTPS essential, because anyone who intercepts the token can impersonate the legitimate holder.
Choosing a character set and length
The security of a random token depends on its entropy, measured in bits. Entropy equals the token length multiplied by the logarithm base 2 of the alphabet size. Here is how the three available character sets compare:
| Character set | Alphabet size | Bits per character | Entropy at 32 chars |
|---|---|---|---|
| Hexadecimal | 16 | 4.00 | 128 bits |
| Alphanumeric | 62 | 5.95 | 190 bits |
| Base64 URL-safe | 64 | 6.00 | 192 bits |
For most applications, 128 bits of entropy is considered strong enough to resist brute-force attacks. A 32-character hexadecimal token meets that threshold. If you need higher assurance, choose alphanumeric or base64url at the same length, or increase the token length.
Common mistakes when handling bearer tokens
Developers frequently make errors that weaken the security of bearer tokens. Avoid these pitfalls:
- Sending tokens over plain HTTP. Always use HTTPS so the header cannot be read in transit.
- Logging the full header. Server logs should mask or truncate tokens to prevent accidental exposure.
- Using predictable values. Timestamps, sequential IDs or short strings are trivially guessable. Use a proper bearer token generator backed by a cryptographic random source instead.
- Storing tokens in local storage on the client. Prefer httpOnly cookies or memory-only storage to reduce cross-site scripting risk.
Bearer tokens versus other authentication schemes
Bearer tokens are one of several ways to authenticate HTTP requests. Basic authentication encodes a username and password in base64, which is reversible and therefore weaker unless combined with TLS. For more complex needs, tools like the basic auth header generator can help construct those headers correctly.
JSON Web Tokens (JWTs) are a structured form of bearer token that carry claims inside the payload. You can inspect them with a JWT decoder or create them with a JWT generator. Opaque tokens generated here have no internal structure, which simplifies validation: the server only needs to look up the string in a database or cache.
If you need general-purpose credentials rather than HTTP-specific ones, an API key and token generator may suit your workflow better.
Worked examples
| Example | Input | Result |
|---|---|---|
| Default 32-char alphanumeric | Token length (characters): 32; Character set: alphanumeric | Authorization header: Authorization: Bearer DtrqLJNBAt5tXDNkVW4DrOv4Kr1Ty6M0; Raw token: DtrqLJNBAt5tXDNkVW4DrOv4Kr1Ty6M0; Token length: 32; Character set: Alphanumeric; Approximate entropy: 190.5 bits |
| 64-char hex token | Token length (characters): 64; Character set: hex | Authorization header: Authorization: Bearer aaa32a86826f7a50b8f00fc3401269d4267aced83d057a83c8308e56c2761cdb; Raw token: aaa32a86826f7a50b8f00fc3401269d4267aced83d057a83c8308e56c2761cdb; Token length: 64; Character set: Hexadecimal; Approximate entropy: 256 bits |
| 48-char base64url token | Token length (characters): 48; Character set: base64url | Authorization header: Authorization: Bearer 2OWnAAKvcOOIviP9zB9gHKuDed6j5tBGrQkO83rj5y-Gz7Gq; Raw token: 2OWnAAKvcOOIviP9zB9gHKuDed6j5tBGrQkO83rj5y-Gz7Gq; Token length: 48; Character set: Base64 URL-safe; Approximate entropy: 288 bits |
FAQ
Is this bearer token generator secure?
Yes. It uses the Web Crypto API to produce cryptographically strong random values. The generation happens entirely in your browser, so the token never travels over the network.
What length should my bearer token be?
At least 32 characters for hexadecimal output, which provides 128 bits of entropy. Shorter tokens are easier to guess, while longer tokens add marginal security at the cost of header size.
Can I use these tokens for OAuth 2.0?
OAuth 2.0 authorization servers issue their own tokens. However, you can use this tool to generate opaque tokens for custom APIs or internal services that follow the same Bearer scheme.
Why does the header say Bearer with a capital B?
RFC 6750 defines the scheme as "Bearer". While HTTP header field names are case-insensitive, the authentication scheme value follows this capitalization by convention.
Should I store bearer tokens in a database?
Store a hashed version of the token, similar to how passwords are handled. If the database is compromised, attackers cannot use the raw hashes to authenticate.
What is the difference between hex and base64url output?
Hex uses 16 characters and produces longer strings for the same entropy. Base64url uses 64 characters, resulting in shorter tokens that are safe for URLs without encoding.