Token Generator
Generate random tokens and strings in hex, alphanumeric, URL-safe, and custom character set formats.
Token Generator tool
Example
Input: Length 32, format Hexadecimal, count 1, then Generate Token
Result: One random 32-character lowercase hex token (characters 0-9 and a-f), different on every run
Each character comes from crypto.getRandomValues. 32 hex characters carry 128 bits of randomness, enough for API keys and session tokens.
Token Length Needed by Format
| Format | Symbols | Bits per character | 128-bit length | 256-bit length |
|---|---|---|---|---|
| Hexadecimal | 16 | 4 | 32 | 64 |
| Alphanumeric | 62 | 5.95 | 22 | 43 |
| URL-safe | 64 | 6 | 22 | 43 |
| Base64 | 64 | 6 | 22 | 43 |
Computed as log2(symbols) per character, rounded up to whole characters.
- Choose the format: hexadecimal, alphanumeric, URL-safe, Base64 or custom character set.
- Set the length (8 to 256 characters) with the slider.
- For a custom set, type the characters to use in the Custom Charset field.
- Set the Count (up to 100) and click Generate.
- Copy one token or all of them with the copy buttons.
Random Token Length and Format Guide
This generator makes random tokens for API keys, session IDs, reset links and invite codes. For anything that protects access, aim for at least 128 bits of randomness. That is 32 hex characters or 22 URL-safe characters.
The format decides how many bits each character carries. Hex uses 16 symbols, so each character is worth 4 bits. Alphanumeric uses 62 symbols, about 5.95 bits each, and URL-safe and Base64 use 64 symbols, 6 bits each. A custom set of N characters gives log2(N) bits per character. Repeated characters in a custom set are removed, so they do not tilt the odds.
Pick the format for where the token will live. Hex is safe everywhere and easy to read in logs. URL-safe uses letters, digits, hyphen and underscore, so it fits into links and file names without escaping. The Base64 option uses standard Base64 with + and /, which must be escaped in URLs, so prefer URL-safe there. Alphanumeric suits codes that people may type.
Random values come from crypto.getRandomValues. For the alphanumeric, URL-safe and custom sets, the tool uses rejection sampling, which throws away values that would make some characters more likely than others. Length runs from 8 to 256 characters, and you can make up to 100 tokens at once and copy one or all. Nothing is sent to a server.
On your server, store a hash of each API key rather than the key itself, so a database leak does not expose working keys. If you need a standard ID format, use the UUID Generator. For passwords that people type, use the Password Generator.
Sources
Frequently Asked Questions
Related Tools
Password Generator
Generate strong, secure passwords with customizable length, character types, and multi-word passphrases.
Security and EncryptionUUID Generator
Generate random UUIDs in v4 and v7 formats with bulk generation and one-click copy support.
Developer ToolsHash Generator
Create MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes of text or files, right in your browser.
Security and EncryptionBasic Auth Generator
Generate Base64-encoded Basic Authentication headers from username and password credentials.
Security and Encryption