crypto.getRandomValues
Generate a random token
A token is a string of random bits. This page draws 8 to 64 bytes and prints hex or base64url, the form often used in URLs.
Hex uses two characters per byte. Base64url uses the URL-safe alphabet and drops the padding equals signs. The length you choose is bytes, not characters, so 32 bytes of hex is 64 characters. The page will not mix in a timestamp or a checksum. It is not an API key registry.
Bytes are drawn in this tab and forgotten when you leave.
This tool runs in your browser. Turn on JavaScript to use it.
Length is counted in bytes
16 bytes is 128 bits. Hex doubles that into 32 characters.
- Bytes
- 16
- Hex length
- 32 characters
- Alphabet
- 0-9 and a-f, or base64url
How to use it
- 1Choose a byte length from 8 to 64.
- 2Choose hex or base64url.
- 3Generate and copy. Do not reuse a sample from the page text.
Good to know
- This is not the password generator. It does not offer a word list.
- Base64url has no + or / and no trailing =.
- The result is not saved.
Questions
How long should a token be?
16 bytes is 128 bits. 32 bytes is a common choice for a bearer token.
Why is base64url shorter than hex?
It packs six bits into a character. Hex packs four.
Is this a signed token?
No. It is random bytes. A JWT is a different page.
Related tools
- Generate a random password
A password from a coin-flip source is stronger than a word you adapted. This page draws each character from the sets you leave on, and then forgets it when you leave.
- Generate a ULID
A ULID sorts by creation time and still has a random tail, so two ids made in the same millisecond are not the same. It is an identifier, not a secret.
- Encode text as hexadecimal
Hex is a way to show raw bytes. This page encodes text as UTF-8 first, then prints each byte. Decoding accepts only an even number of digits and rejects bytes that are not UTF-8.