Xerobit

Random String Generator for Tokens and Keys

This random string generator creates sequences of random characters for API tokens, session keys, passwords and test data. Pick a length, choose which character types to include and generate one or many strings at once. Everything runs locally in your browser so nothing is uploaded anywhere.

Result

  1. yevOrgzPsFgZmFMFGFieJ733jItA28LA

How to use the random string generator

  1. Set the string length to the number of characters you need for your token or identifier.
  2. Check the boxes for the character sets you want: lowercase, uppercase, digits or symbols.
  3. Choose how many strings to generate at once using the How many field.
  4. Click Generate to produce your random strings instantly.

How the randomness works

This random string generator uses the Web Crypto API (crypto.getRandomValues) to pick each character. Unlike Math.random(), which relies on a predictable pseudo-random algorithm, the Web Crypto API draws from an operating-system-level entropy source. That makes it suitable for security-sensitive values like session tokens and API keys.

The tool first builds a pool of allowed characters based on your checkbox selections. For example, choosing lowercase and digits creates a pool of 36 characters (26 letters plus 10 digits). It then selects one character at a time from that pool using a uniformly distributed random index until the string reaches the requested length.

Entropy and string strength

The strength of a random string depends on its length and the size of the character pool. Entropy is measured in bits and calculated as log2(pool_size) * length.

Character setPool sizeBits per char32-char entropy
Hex (0-9, a-f)164.00128 bits
Alphanumeric (a-z, A-Z, 0-9)625.95190 bits
Alphanumeric + symbols946.55210 bits

A 128-bit entropy value is generally considered secure against brute-force attacks for most applications. If you need stronger guarantees, increase the length or add symbols to expand the pool.

Common use cases

Developers and testers use random strings for many tasks:

  • API tokens and keys: Services like Stripe or GitHub expect long, unpredictable strings to authenticate requests.
  • Session identifiers: Web servers assign a unique cookie value to each visitor. A 32-character alphanumeric string provides ample entropy.
  • Password reset links: A temporary token embedded in a URL must be unguessable to prevent account takeover.
  • Test fixtures: When seeding a database with sample records, you often need unique names or reference codes. Generating multiple strings at once speeds this up.
  • Salts for hashing: Adding a random string to a password before hashing prevents precomputed dictionary attacks.

If you only need numbers rather than full alphanumeric strings, a random number generator may be more appropriate.

Choosing the right character set

Not every system accepts every character. Before generating a token, check what the receiving service allows.

  • Hexadecimal (digits + lowercase a-f): Common for UUIDs and cryptographic hashes. Use the digits and lowercase options, but note this tool includes all 26 letters, not just a through f. For strict hex, use a dedicated UUID generator.
  • Base64url: Uses A-Z, a-z, 0-9, hyphen and underscore. Enable uppercase, lowercase and digits, then manually replace any unwanted characters if needed.
  • URL-safe tokens: Avoid symbols like #, & and ? because they have special meaning in URLs. Stick to alphanumeric characters for query parameters.
  • Passwords: Include all four character sets to maximize entropy and meet typical complexity requirements.

Mistakes to avoid

Using a weak source of randomness is the most common mistake. Never rely on timestamps, sequential counters or Math.random() for anything security-related. This tool avoids that pitfall by using the Web Crypto API exclusively.

Another issue is making strings too short. A six-character alphanumeric string has about 35 bits of entropy, which can be brute-forced in hours on modern hardware. For authentication tokens, aim for at least 128 bits, which means 22 or more alphanumeric characters.

Finally, do not reuse random strings across different systems. Each token should be generated independently. The batch feature here lets you create multiple unique strings at once without repeating values.

Worked examples

Each result below was produced by the same code the tool runs, so you can check your own numbers against them.

ExampleInputResult
32-char hex-style tokenString length: 32; How many: 1; Lowercase (a-z): yes; Uppercase (A-Z): no; Digits (0-9): yes; Symbols (!@#$...): noc6nifdesf76fq6byhuwkotwsvd2p4v50
API key with symbolsString length: 64; How many: 1; Lowercase (a-z): yes; Uppercase (A-Z): yes; Digits (0-9): yes; Symbols (!@#$...): yes!ByhVAS$S*nTKG{AoRqf8))tC.g]*^#ERgpCf[jR2cKRI2UN;(}M%h.@m08_%pi[
Five short numeric PINsString length: 6; How many: 5; Lowercase (a-z): no; Uppercase (A-Z): no; Digits (0-9): yes; Symbols (!@#$...): no414572, 776341, 251706, 042834, 172580
Batch of UUID-length stringsString length: 36; How many: 10; Lowercase (a-z): yes; Uppercase (A-Z): no; Digits (0-9): yes; Symbols (!@#$...): noxwpozrdkwjla0fknv5jdxc2sv84cdmvsafie, nvxmp20yc7n3nmi0zkiic28z9q9voph39knl, vuxe15ver4fhjgk9hru4wxpevqxc40tolrbc, hdjeztqtzsdo1bolguwqnfktnnikllvy6lvo, 0u02s4dbrpib7lpftwaku5ezky4l5w0bzn5f, u9kzj5b4wxgarniv09dkvfjd1r286y8frblo, sf7w2ld33wku6h3iwbz481q2zsck9v46wn0h, nswj32luabrikahkzcsgcq62eetsph3tp1vl, uamhbcnqy1ebfn6y47kkc1okc9puzhmload9, 0hzvjmlnw6xhd5a6k7ffl5ip8ekwzngfvda4

FAQ

Is this random string generator cryptographically secure?

Yes. It uses the Web Crypto API, which draws from the operating system's entropy pool. This makes it suitable for generating API keys, session tokens and other security-sensitive values.

What is the maximum string length I can generate?

You can generate strings up to 4,096 characters long. For most tokens and identifiers, 32 to 64 characters provide more than enough entropy.

Can I generate only numbers or only letters?

Yes. Uncheck the character sets you do not want. If you select only digits, the output will be a numeric string. You must leave at least one character set enabled.

Are the generated strings sent to a server?

No. All generation happens locally in your browser using JavaScript. Nothing is transmitted over the network, so your tokens remain private.

How many strings can I generate at once?

You can generate between 1 and 100 strings in a single batch. Each string is produced independently, so there are no duplicates by design.

Should I include symbols in my tokens?

It depends on where the token will be used. Symbols increase entropy but can cause issues in URLs, HTTP headers or legacy systems. For API keys stored in databases, symbols are fine. For URL parameters, stick to alphanumeric characters.