Secure Token Generator
Generate cryptographically random tokens in hex, URL-safe or unambiguous alphabets for API keys, session IDs and secrets.
Everything on this page happens in your browser. Generated secrets are never sent anywhere, never logged and never stored — close the tab and they are gone, so copy anything you need first.
What the Secure Token Generator does
This secure token generator will generate cryptographically random tokens in hex, URL-safe or unambiguous alphabets for API keys, session IDs and secrets. Paste your text in, pick the options you need, and copy the result straight back out. It is most often used for generating an API key or client secret for a service you are building. If you need the other side of this job, there is also a brute force time calculator.
How to use it
- Choose the alphabet your target system needs — URL-safe for anything that travels in a URL, hex for config files.
- Set the length, checking the entropy figure as you go. Aim for 128 bits for a long-lived secret.
- Add a prefix if your system uses one to identify the key type, as many APIs do.
- Copy the token straight into your secret store. Do not paste it into a chat window, a ticket or a commit.
How it works
A token used as a secret needs to be unguessable, which means it must come from a cryptographically secure generator and have enough entropy that searching the space is hopeless. This page uses crypto.getRandomValues with rejection sampling, so each character is uniformly drawn from the chosen alphabet with no modulo bias. The widely used convention is 128 bits or more for anything long-lived — an API key, a password-reset token, a session identifier — and the verdict row tells you whether your settings clear that bar.
The alphabet matters less than the length. Hex characters carry 4 bits each, so a 32-character hex token is 128 bits; URL-safe base64 characters carry 6 bits each, so 22 characters reach the same strength. Hex is longer for the same security but is unambiguous and trivially parseable, which is why it remains common in configuration files.
The URL-safe alphabet exists because tokens end up in places that treat some characters specially. Standard base64 uses + and / and pads with =, all of which need percent-encoding in a query string and can be mangled by anything that re-encodes a URL. Swapping in - and _ and dropping the padding avoids that entirely, which is what RFC 4648's URL-safe variant specifies.
The unambiguous alphabet drops 0, O, 1, l and I, and exists for codes a human has to read off a screen or a printed card and type somewhere else. It costs you entropy per character — 5 bits instead of 6 — so an unambiguous token needs to be about 20% longer for the same strength, which is a reasonable trade when the alternative is support calls about whether that character was a one or an ell.
When to use it
- Generating an API key or client secret for a service you are building.
- Creating a session identifier or CSRF token for testing.
- Producing a password-reset or email-verification token.
- Generating a webhook signing secret.
Common mistakes to avoid
- Using a token under about 80 bits as a long-lived secret. Short tokens are feasible to search offline.
- Putting a standard base64 token in a URL without encoding it. The + and / characters will be mangled.
- Committing a generated secret to a repository. Rotate anything that has touched version control, a chat log or a screenshot.
Frequently asked questions
How long should an API key be?
Long enough for 128 bits of entropy or more: 32 hex characters, or 22 URL-safe base64 characters. Many services use more, which costs nothing and leaves room for a prefix and a checksum.
Is this random enough for production secrets?
The randomness comes from the Web Crypto API, which is the same CSPRNG your browser uses for TLS, so yes on that count. The practical caveat is that a secret should ideally be generated on the machine that will hold it, so that it never travels anywhere — including across your own clipboard.
What does the prefix do?
Nothing cryptographically. It is a convention — keys that start with a recognisable tag are easier to identify in logs and can be detected by secret scanners before they leak, which is why many APIs use one.