b2KIT

Random String Generator

Create cryptographically random strings for API keys, tokens, salts, and unique identifiers.

How to Use Random String Generator

  1. 1

    Set the length

    Choose how many characters the random string should contain.

  2. 2

    Select character types

    Toggle letters, numbers, special characters, and case.

  3. 3

    Generate and copy

    Click generate and copy the random string to your clipboard.

Tested tool guide Tested browser tools Checked August 16, 2026

What Random String Generator does and how it behaves

This tool generates a string from the browser's cryptographic random source - the same class of randomness browsers use for TLS keys - rather than the predictable pseudorandom generator behind Math.random(). You choose the length and character set, and each generation is computed locally in the page, so a secret never leaves your machine. The thing most users get wrong is scale: strength is length multiplied by alphabet size, so a 22-character alphanumeric string already exceeds 128 bits of entropy, while 16 characters of lowercase letters is only about 75 bits and brute-forceable. Generate what you need, not the longest option.

How the result is produced

1

Entropy per character

Each position contributes log2 of the alphabet size in bits of uncertainty: about 5.95 bits per character for 62 alphanumeric symbols (a-z, A-Z, 0-9) and about 6.55 bits per character for the 94 printable ASCII characters. Total entropy is length times that figure, so a 32-character alphanumeric string holds roughly 190 bits. This is why short, non-obvious strings already defeat brute force.

2

Randomness source

The generator draws from the browser's cryptographically secure random source, the same primitive browsers use to create session keys. Characters are selected independently and uniformly from the alphabet you chose, and the stream cannot be predicted from earlier values. That property is what makes the output acceptable as secret material: knowing part of a generated string gives no help guessing the rest.

Good uses

  • Generate an API key or OAuth client secret when you provision a new integration, save the master copy to a password manager, and never display it again in plain text.
  • Create a fresh, unpredictable salt for each user's password hash so that two users with the same password never produce the same hash, and precomputed rainbow tables are useless.
  • Produce unique database identifiers or idempotency keys for payment retries, where a duplicate value could corrupt records or double-charge a customer.

Limits and checks

  • Length is characters, not bits. A 16-character alphanumeric string carries about 95 bits of entropy - under the 128-bit threshold commonly cited for secret material - while 22 alphanumeric characters clear it. Read the alphabet and the length together before trusting a string.
  • The output exists only in this page and there is no history or recovery. Close the tab or let the clipboard get overwritten and the value is gone; if it was already deployed as a secret, rotation is the only fix.
  • Cryptographic randomness does not rescue a short string. A 6-character code drawn from a perfect random source still has only about 36 bits of entropy with the alphanumeric set, and is trivially brute-forced. Randomness decides unpredictability; length decides the search space.

Common questions

Is it safe to use the output as a production API key?

The randomness is appropriate for secrets: output comes from the browser's cryptographic random source, so it cannot be predicted or replayed. The risks live around the page - save the value to a vault before closing the tab, never commit it to a repository, and treat any appearance in a log or error message as a leak that requires rotating the key.

How long should I make the string?

Enough to clear about 128 bits of entropy: 22 characters with the alphanumeric set, 20 with full printable ASCII. Beyond roughly 256 bits, extra characters add nothing against brute force, so longer is not meaningfully safer. For a non-secret such as a demo ID, 12-16 characters is plenty; match length to what the value protects.

References and verification

The behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools