Skip to content
M2TOOLKIT

Security · free tool

Random Token & API Key Generator

Generate secure random strings for API keys, secrets, session tokens and test data.

Use it as often as you like — it's free, with no sign-up and no limits.

  • Security
  • Free
  • No sign-up
  • Runs in your browser
  • Updated
Format
32

128 bits or more is recommended for API keys and session secrets. All values come from crypto.getRandomValues.

Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us.

How to use the Random Token Generator

  1. Choose a format and length.
  2. Choose how many tokens.
  3. Copy or download them.

What does this tool do?

Tokens are built from crypto.getRandomValues. Base64URL and hex formats are generated from random bytes, so 32 bytes always means 256 bits of randomness. Character-set formats use unbiased selection from the alphabet you choose.

Formats, lengths and how much randomness you get

Base64URL and hex tokens are built from random bytes, and the slider sets the number of bytes. 32 bytes is 256 bits, which is 43 characters in Base64URL (letters, digits, - and _, safe in URLs and file names) or 64 characters in hex. The A–Z a–z 0–9 and Custom formats pick each character separately with unbiased selection, and the slider sets the number of characters: each alphanumeric character adds about 5.95 bits, so 22 characters give about 131 bits.

The label above the output shows the estimated strength in bits for your settings. 128 bits or more is the usual recommendation for API keys, session tokens and signing secrets. You can make 1 to 100 tokens at once, from 8 to 128 bytes or characters each.

Handling secrets safely

Tokens are generated with crypto.getRandomValues on your device and never sent anywhere, but a secret is only as safe as where you put it. Store it in a secrets manager or environment variable, not in source code or a shared document, and rotate it if it's ever exposed. Generate a separate secret for each environment and service, so one leak doesn't unlock everything.

Related: Password Generator

Why use it?

  • Secrets for JWT signing, webhooks and sessions.
  • Invite codes with unambiguous characters.
  • Bulk test data.

Use cases

  • API keys and webhook signing secrets.
  • Session and CSRF tokens in development.
  • Unique IDs and test data.
  • Invite and reset codes.

How long should a secret be?

128 bits (16 bytes) is the practical minimum for secrets; 256 bits (32 bytes) is common for signing keys.

Common mistakes

  • Making secrets with Math.random() or timestamps, which are predictable.
  • Committing a generated secret to a Git repository, even briefly.
  • Using a short custom alphabet without making the token longer to compensate.

Privacy

Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us. There's no account to create and nothing to install.

Frequently asked questions

Is it safe to do this in a browser?

Yes, because nothing leaves your device. Everything is generated or checked with your browser's built-in cryptography (the Web Crypto API) — no network requests are made with what you type.

How long should an API key or secret be?

At least 128 bits of randomness, and 256 bits is a common choice. 32 random bytes gives 256 bits, which is 64 hex characters or 43 Base64URL characters.

Content last updated . See how M2Toolkit works.

Other tools people use alongside the random token generator.