Free · runs in your browser

Random Token Generator

Random Token Generator. Set a byte length and format to instantly generate a cryptographically random token. Webhook secrets and service-to-service tokens are quick to produce with the api key generator in hex or base64url.

Your values

Hex and Base64url are safe in URLs and headers. UUID v4 has a fixed 36-character layout.

Generate 1 to 50 tokens at once.

Random characters after any prefix. 32 is a solid default for API keys; use 64 for long-lived secrets. Ignored for UUID v4.

Character sets

Symbols add entropy per character but may need escaping in URLs, headers and config files.

Added to the front of each token to label its type or environment. It adds no entropy. Spaces are removed, up to 32 characters.

Result

Generated token
—
All generated tokens (copy)
—
Entropy per token
—
Random characters
—
Total length incl. prefix
—
Tokens generated
—
  • No account, no logging
  • Open formulas explained below
  • Works offline once loaded

Need a value nobody can guess? A random token generator builds API credentials, session identifiers and signing keys in your browser, computing each one locally with nothing sent to a server. Pick a length, take the result, and you hold a high-entropy string that is ready to drop into your API project.

How a Random Token Generator Works

A generator is only as strong as its source of unpredictability. Behind the button sits a random number generator built for cryptographic work, not the casual kind used to shuffle a playlist. Each click draws fresh bytes, turns them into characters and shows you the result. For a new Rails app, the free rails secret key base generator returns a 128 character hex value equal to what SecureRandom.hex(64) gives.

Cryptographically Secure Randomness (CSPRNG)

Your operating system gathers entropy from hardware events and feeds a cryptographically secure generator, usually shortened to CSPRNG. Its output is statistically indistinguishable from noise, so an attacker who sees a thousand tokens still cannot predict the next one. General-purpose math functions are not in this class and should never mint a credential, because a predictable value is a security hole from the first request.

Base64 Encoding and Entropy

Raw bytes are not typeable, so the tool applies Base64, mapping every 6 bits to one printable character. Strength is measured in entropy, and NIST SP 800-90A describes the approved ways to produce it, which makes it the usual reference for standards in this area:

Formula card showing 192 bits equals 32 Base64URL characters times 6 bits, with bars ranking bits per character for Base64URL, alphanumeric, Base32 and hex token encodings
Each character adds log2(N) bits of entropy, so bigger alphabets give shorter tokens at the same bit length.

$$\text{entropy (bits)} = L \times \log_2(N)$$

Here L is the length and N is the size of the alphabet.

API Token Generator Options

A handful of settings decide what you get. This random API token generator keeps them to length, prefix and character set, and each matters most where compliance rules apply, such as financial or healthcare systems and critical infrastructure. Developers using GCM or CBC pair the aes encryption key generator with a fresh initialization vector for every message.

Bit Length Selection

Bit length sets how much entropy a token carries, and every extra bit doubles the guesses an attacker needs:

Heatmap of random token length in characters for 64 to 384 bit lengths across hex, Base32, letters and digits, and Base64URL encodings, with the 192-bit Base64URL cell outlined
Characters needed for each bit length and encoding; the worked 192-bit example is outlined.
  • 128-bit: the floor for production services.
  • 256-bit: high security for payments and patient records.
  • 512-bit: long-lived credentials where rotation is painful.

Custom Token Prefixes

A short label such as tok_ or live_ tells your team which kind of token they are holding and helps scanners flag a leak. Use a different prefix for development and live systems. A prefix adds no entropy, so leave it out of your length maths.

API Keys vs Tokens: Alphanumeric Characters and Symbols

API keys are usually alphanumeric, which keeps them safe inside URLs, filenames and fussy parsers. A token can widen its character set with symbols instead. Which key style you choose therefore comes down to compatibility: pick the alphanumeric style whenever the receiving system is strict about what it accepts. Whichever you pick, the API only stays safe if the value is long enough: weak API keys are the most common security gap in small projects, and reused API keys make it worse.

Special Characters and URL Encoding

Adding special characters such as + and / lifts the alphabet from 62 to 70. A 24-character alphanumeric string then holds about 142.9 bits of entropy, while the 70-character version reaches 147.1. The catch is URL encoding: a token with + or = inside a query string needs escaping, or the server reads the wrong value. At 256-bit strength, though, either alphabet is far beyond brute force.

Bearer Tokens and Access Tokens in Production

These values mostly travel in HTTP headers. Bearer tokens prove who is calling, access tokens carry scoped permissions, and refresh tokens mint new ones after expiry. Session tokens keep a login alive, while JWT tokens are structured payloads whose JWT secrets must be long and random. In production, OAuth flows and other authentication tokens all lean on the same property: an outsider cannot guess the next value. Good API security also means scoping, so give each API client its own token and a leak stays contained.

Timeline of average brute-force time for a secure token from 64 to 192 bits of entropy at one trillion guesses per second
Average brute-force time at one trillion guesses per second: 128 bits is the practical production floor.

Sizing JWT Tokens for a Payments Webhook

I am wiring a payments webhook, and the provider signs each call with HS256, so I need a signing secret before I can ship. I open the generator, choose the 62-character alphanumeric set, set the length to 40 and add the prefix whsec_, which makes the value easy to spot later in logs and secret scanners.

The page returns a value instantly. Before pasting it anywhere, I run the entropy formula: 40 × log2(62) = 238.2 bits. That looks generous, but RFC 7518 says an HMAC key for HS256 should be at least as long as the hash output, which is 256 bits. My value falls 17.8 bits short, so every token signed with it would sit below the standard.

Sizing JWT Tokens for a Payments Webhook
LengthAlphabetEntropyVerdict
4062238.2 bitsShort of 256
4070 (with symbols)245.2 bitsStill short
4362256.0 bitsMeets HS256

The sensitivity rerun is the useful part. Adding symbols helps only by 7 bits, so the number to watch is length: 256 ÷ 5.954 = 42.99, which rounds up to 43 characters. I regenerate at 44 for a little headroom, which gives 262.0 bits, and store it in the team vault. As a cross-check, I recompute it with base-10 logarithms: 44 × 1.7924 ÷ 0.30103 = 261.97, which matches.

Two caveats. The prefix adds no entropy, so I never count it toward the 43. And the formula only holds when every character is drawn uniformly at random; a value I typed or trimmed by hand would carry far fewer bits than the arithmetic claims, so I would not trust it on its own. In that case the fix is simply to regenerate the whole string, because trimming characters also trims the entropy you just calculated and leaves you below the threshold again.

Generate Secure API Tokens in Your Browser

The routine takes seconds:

  1. Choose a bit length, such as 256-bit.
  2. Add an optional prefix.
  3. Press generate, then export the values as text if you need several.

Copy and Store Securely

After the generator returns a value, copy the token straight into your secret store, not into chat or email. If you cannot store securely right away, regenerate later rather than leave it in a clipboard history, and never reuse one generated password-style value across two services, since a single leak would then open both.

Web Crypto API and Local Generation

Because the page runs client-side, it can call the Web Crypto API, a real security win over home-grown scripts, whose getRandomValues function fills a buffer from the same CSPRNG your operating system uses. Open your network tab, regenerate, and you will see no request leave the page.

API Key Generator Security Best Practices for Secrets

Generation is the easy half. What you do next decides whether your API credentials stay safe, so treat every secret like a password. The same hygiene applies to API account security: one unique value per service, never shared between teams.

  • Never commit a value to version control.
  • Keep production values in a secrets manager and personal passwords in a password manager.
  • Encrypt storage at rest and send values over HTTPS only.
  • Use a hash or redaction in logging, never plain text.

Rotation, Expiration and Revocation

Set a rotation schedule, regenerate a fresh token with the generator at each cycle, and an expiration date for each credential, and revoke one the moment you suspect compromise. Short-lived tokens limit the damage if a log or backup ever leaks.

Random String Generator Uses in Development and Testing

Not every value is a credential. Use the same tool for fixtures, test accounts and throwaway passwords while testing. A hex string suits a cache key, a UUID works as a unique row identifier, and a few words make easy passphrases. Store them as environment variables so each developer keeps their own value. The tool can also seed encryption setups with encryption keys for local databases, and you can script any keygen routine around it. Short test values are fine here; never reuse them as real credentials.

Frequently Asked Questions

What's the difference between the formats?
They're all encodings of the same random bytes, not different levels of randomness. Hex uses 2 characters per byte and only 0-9a-f (safest for shells and config files); Base64 packs 3 bytes into 4 characters using 64 symbols including + and /; Base64URL is the same but URL-safe (- and _ instead); Alphanumeric skips byte-encoding entirely and draws directly from a 62-character letters+digits set, useful when symbols like +, /, or = would break a system that only expects word characters.
How many bytes should I use?
32 bytes (256 bits) is a strong general-purpose default for session tokens, API keys, and CSRF tokens. Use 16 bytes (128 bits) for shorter-lived, lower-stakes tokens where length matters for usability; go up to 64 bytes for long-term secrets you want an extra security margin on.
Is alphanumeric output as secure as hex or Base64 at the same byte length?
Not quite in raw bit terms, since it draws each character independently from a 62-symbol alphabet rather than encoding true random bytes, but the practical difference is negligible at normal lengths -- a 32-character alphanumeric token still has roughly 190 bits of entropy (32 × log2(62)), far beyond what's needed for any realistic token use case.
Can I use this for API keys, session tokens, and CSRF tokens?
Yes -- this is exactly the kind of general-purpose random value those all need: a cryptographically unpredictable string with no exploitable pattern. Choose the format that matches where you're pasting it (URL-safe for query parameters, hex for config files, etc.).
Is this token sent anywhere when generated?
No. It's generated entirely in your browser using the Web Crypto API's cryptographically secure random number generator -- nothing is transmitted, logged, or stored.

About the author

Vinitha Pu

Founder and designer

Vinitha Pu is a graphic designer based in Palakkad, Kerala, who builds free, privacy-friendly browser tools. She studied Textile and Apparel Design at Avinashilingam University and completed a C-Tech in Graphic Design at Image Creative Education in 2025. She designs, builds and maintains the password generators, strength checkers, hash tools and security calculators on PasswordHive.

  • Content author: Vinitha Pu
  • Fact checked by: Vinitha Pu. Each tool's output is checked against official test vectors or a reference implementation, and every strength and crack-time figure against the formula it uses, before it goes live.
  • Published Updated