About the Random Token Generator
This FreeToolr tool generates cryptographically random tokens locally in your browser. You pick the encoding (Hex, Base64url, Base64 or letters-and-numbers), the number of random bytes, how many tokens and an optional prefix such as sk_live_. The tool uses the Web Crypto API crypto.getRandomValues to fill raw bytes, encodes them per the chosen format and shows tokens, the randomness in bits and the character count (without any prefix). Nothing is uploaded or sent to our servers; the page runs entirely client-side. Results update instantly as you type and there is no calculate button. You can copy tokens or share a link that reopens the page with your settings. Use 128 bits (16 bytes) for session IDs and 256 bits (32 bytes) for API keys and secrets. Keep tokens out of URLs that end up in logs.
How to use it
- 1Choose Format: Hex, Base64url, Base64 or Letters and numbers.
- 2Pick Random bytes: 16, 24, 32, 48 or 64.
- 3Set How many tokens and an optional Prefix, for example sk_live_.
- 4Copy tokens or use the share link to reopen the page with your settings.
Worked example
Input: Format = Base64url, Random bytes = 32, How many = 1, Prefix = sk_live_. Result: Randomness = 256 bits, Characters per token (without prefix) = 43, Token shown as sk_live_ followed by 43 Base64url characters.
How it works
Hex, Base64 and Base64url tokens encode raw bytes from crypto.getRandomValues: hex uses 2 characters per byte, Base64 uses 4 characters per 3 bytes (with = padding), Base64url uses the same alphabet with - and _ and no paddingLetters-and-numbers tokens pick from 62 characters with rejection sampling and are made long enough to hold at least the same number of bits: length = bits / log2(62), rounded upSource: MDN Web Docs - Crypto.getRandomValuesRFC 4648 - Base64, Base64urlOWASP Session Management Cheat Sheet. Last checked 5 November 2026.
What it is good for
- You get CSPRNG tokens made locally with crypto.getRandomValues.
- You can pick encoding and bytes to match your systems or policies.
- Results update instantly and you can copy or share a link with settings.
- Browser generation uses Web Crypto; for regulated production you may need server-side, FIPS/NIST-approved RNGs and lifecycle controls.
- Do not expose tokens in URLs that go into logs or third-party systems.
Questions people ask
How many bits should I pick for a token?
128 bits (16 bytes) is enough for session IDs and reset links. Use 256 bits (32 bytes) as a default for API keys and long-lived secrets. These are common recommendations from OWASP.
Is it safe to generate tokens in the browser?
For one-off keys, tests or client-side needs, yes: browsers provide crypto.getRandomValues, a cryptographically secure RNG. For production authentication or regulated systems, generate and store tokens server-side with an approved RNG and proper key management.
Which encoding should I use for URLs and headers?
Use Base64url without padding for shorter, URL-safe tokens. Use hex only when a system specifically requires hex. Base64 is longer when padded with = characters.
How do I know how many characters a token will have?
Bits = 8 × bytes. Hex length = 2 × bytes. Base64url length ≈ ceil(4 × bytes / 3). For example 32 bytes = 256 bits = 64 hex chars ≈ 43 Base64url chars.
Can I control the token prefix?
Yes. You can add an optional prefix such as sk_live_. The prefix is not counted in the displayed characters per token value.
Does FreeToolr send my data to a server?
No. Tokens are generated in your browser using the Web Crypto API. Nothing is uploaded by the tool when you generate tokens; only you can copy or share the link with settings.
Help keep every tool free
FreeToolr stays free because people help it grow. Share a tool you like, tell us what to build next, or support us on Ko-fi.