U.UtilityApp
⚙️ DevFree · No signup

Random Token / API Key Generator

Generate secure random tokens and API-key-style strings using the browser's crypto API.

Hex output, measured in characters

The token is lowercase hexadecimal: digits 0 to 9 and letters a to f. The slider sets its length in hex characters, from 8 to 128 in steps of 2, and starts at 32. Every two characters represent one random byte, read straight from crypto.getRandomValues, so each character carries exactly 4 bits and there is no rounding or skew.

SliderBytesBitsTypical use
16864Non-secret IDs, cache-busting values
3216128API keys, session IDs, reset tokens
6432256Webhook signing secrets, HMAC keys
12864512Keys where a spec asks for 64 bytes

A token is created when the page loads. Moving the slider doesn't change it, so press Generate token after picking a length.

Turning it into an API key your users will recognise

The tool outputs bare hex, like c274ac01919379ab807d1dc253907264. Many services add a short prefix that names the key type and environment, which makes leaked keys easy to spot in logs and code reviews. Add it yourself, for example myapp_test_ or myapp_live_ in front of the token. The prefix adds no secrecy, so keep the random part at full length.

When a library asks for a key as bytes rather than text, a 64-character token decodes from hex into exactly 32 bytes. Check whether the library expects the hex string itself or the decoded bytes. Mix the two up and two systems will compute different signatures from what looks like the same secret.

After you generate it

  • Show it once. If you issue keys to users, display the full key a single time and keep only a hash of it on the server, plus the last four characters for identification.
  • Keep it out of source code. Put it in an environment variable or a secrets manager. Hex contains no characters that need quoting, so it pastes cleanly into .env files and CI settings.
  • Compare it safely. When checking a presented token, use your language's constant-time comparison function rather than ==.
  • Plan for rotation. Generate the replacement before revoking the old token, so services can switch over without downtime.

Frequently asked questions

Why does the token only use 0–9 and a–f?+

Hex is unambiguous: it survives uppercasing, email clients and copy-paste between systems without any character changing meaning. The trade-off is length, since each character carries 4 bits instead of about 6 for mixed-case letters and digits.

Is a 32-character token the same as a UUID?+

No. Both are 32 hex digits once a UUID's hyphens are removed, but a version 4 UUID fixes some of its digits as version and variant markers. Every character of this token is random.

Can I get the token in Base64?+

Not from this page. You can convert the hex to bytes and then to Base64 in most languages with a couple of standard library calls, which gives a shorter string with the same randomness.

Is the token stored anywhere?+

No. It is generated in your browser and replaced the next time you press the button, so copy it into your secrets store straight away.

Embed this tool on your website

Free to use on blogs, school sites and intranets. Paste this code into your page's HTML; please keep the credit line.

<iframe src="https://utilityapp.lat/embed/dev/token-generator" title="Random Token / API Key Generator" width="100%" height="600" style="border:0;max-width:760px" loading="lazy"></iframe>
<p style="font-size:13px"><a href="https://utilityapp.lat/dev/token-generator">Random Token / API Key Generator</a> by UtilityApp</p>