Random String Generator

A free tool by DeepRit, a Google Ads agency that does PPC and nothing else. We build and run Google Ads accounts so every click is accounted for. Book a free audit call

Free random string generator. Make secure random strings of any length from letters, digits, symbols or your own characters, for IDs, codes and keys.

Random strings
Characters to choose from
0
Strength (bits)
0

Free, no sign-up. Runs in your browser: nothing you type is uploaded or saved.

How to use the random string generator

  1. Set the length of each string, from 1 to 4,096 characters.
  2. Set how many strings you want, up to 500 at once.
  3. Choose the characters: uppercase A–Z, lowercase a–z, digits 0–9 and symbols. You can also add your own characters in the "Extra characters" box.
  4. Tick "Avoid look-alikes" to remove characters that are easy to confuse, such as O and 0, or I, l and 1. This is useful for codes people will read or type.
  5. Press Generate for a new batch. Copy the strings with one click.

The random string generator also shows how many characters it's choosing from and the strength of each string in bits of entropy.

Every string is created in your browser using your device's cryptographically secure random number generator. Nothing is sent to a server, logged or stored.

How the strings are generated

The random string generator uses the Web Crypto API (crypto.getRandomValues), the same source of randomness browsers use for security. That matters, because ordinary random functions like JavaScript's Math.random aren't designed to be unpredictable and shouldn't be used for anything security-related.

It also avoids modulo bias, a subtle flaw in many simple generators. If you pick a random number from 0 to 4,294,967,295 and take the remainder after dividing by 62, some characters come up very slightly more often than others. This generator rejects the values that would cause that imbalance, so every character in the pool is exactly equally likely.

Entropy: how strong is a random string?

The strength of a truly random string is measured in bits of entropy:

Entropy = length × log₂(number of possible characters)

  • 16 characters from letters and digits (62 possibilities each): 16 × log₂(62) ≈ 95.3 bits.
  • 12 characters from uppercase letters and digits (36 possibilities): 12 × log₂(36) ≈ 62.0 bits.
  • 32 lowercase hex characters (16 possibilities): 128 bits.

Each extra bit doubles the number of possible strings. For context:

  • Under about 40 bits: fine for things like short invite codes that are rate-limited, but guessable by brute force otherwise.
  • About 64 bits: reasonable for many identifiers and one-time codes with limits on attempts.
  • 80 bits or more: strong for most purposes.
  • 128 bits or more: the usual target for secret keys and tokens.

Length adds strength faster than adding character types. A 20-character string of lowercase letters (94 bits) is stronger than a 12-character string using every symbol (78 bits).

Common uses for random strings

  • API keys and tokens for development and testing.
  • Database IDs and slugs that shouldn't be guessable.
  • Coupon, voucher and referral codes. Use "Avoid look-alikes" and uppercase letters with digits so customers can type them.
  • Invite and access codes for events or beta programmes.
  • Test data for forms and databases.
  • Session secrets and salts in configuration files.
  • File names that won't clash.

For human passwords, the password generator adds strength ratings and password-specific options. For standard unique identifiers, the UUID generator creates version 4 and version 7 UUIDs. For random numbers in a range, use the random number generator, and for random letters only, the random letter generator.

Choosing a character set

Character set Characters Bits per character
Digits only 10 3.32
Hex (0–9, a–f) 16 4
Lowercase letters 26 4.70
Uppercase + digits 36 5.17
Letters + digits 62 5.95
Letters + digits + symbols 87 6.44

Some practical tips:

  • URLs: letters, digits, hyphen and underscore are safe in URLs. Avoid symbols like &, ?, # and / unless you'll encode them.
  • Codes read aloud or printed: uppercase and digits, with look-alikes removed.
  • Config files and environment variables: avoid quotes, backslashes and $ signs, which can be misread by shells.
  • Hex strings: use the extra characters box with only 0123456789abcdef and untick the other sets.

Uniqueness and collisions

Random strings aren't guaranteed to be unique, but with enough entropy, duplicates become vanishingly unlikely. Because of the "birthday problem", collisions become likely once you've generated roughly 2^(bits ÷ 2) strings. At 64 bits, that's about 4 billion; at 95 bits, about 280 trillion. For codes stored in a database, add a unique constraint anyway, and generate a new code if one ever clashes.

Keep secrets secret

A random string is only as safe as where you keep it. Don't paste real secret keys into chat apps, public repositories or screenshots. Store them in a password manager or a secrets manager, and rotate them if they're exposed. For hashing values rather than storing them, the hash generator creates SHA-256 and other hashes; to encode binary data as text, use the Base64 encoder.

Random strings in code

If you need random strings inside an application, generate them in code using a secure source:

  • JavaScript (browser and Node.js): crypto.getRandomValues for random bytes, or crypto.randomUUID for a UUID. In Node.js, crypto.randomBytes(16).toString("hex") gives 32 hex characters.
  • Python: the secrets module, such as secrets.token_urlsafe(16) or secrets.token_hex(16).
  • PHP: random_bytes or random_int.
  • Command line: openssl rand -hex 16 or openssl rand -base64 24.

Avoid functions like Math.random in JavaScript or the random module in Python for anything security-related, because their output can be predicted. The random string generator uses the browser's secure source, so it's safe for creating keys by hand during development and setup.

Readable codes for customers

If people need to read or type a code, make it easy:

  • Use uppercase letters and digits, and tick "Avoid look-alikes".
  • Keep it short enough to type, often 8 to 12 characters.
  • Group characters, for example ABCD-EFGH-JKLM, which you can do by adding hyphens after generating.
  • Check codes against your database, and limit how many guesses are allowed, so short codes stay safe.

Random strings and privacy

Random identifiers are useful for privacy: instead of exposing sequential order numbers or user IDs (which reveal how many orders or users you have, and let people guess others), use random strings in URLs and public references. A 16-character random string from letters and digits is effectively impossible to guess, which the strength figure in the random string generator confirms.

Random strings for testing

Random strings are useful test data. Generate a batch with the random string generator to test how forms, databases and APIs handle long inputs, unusual characters and maximum lengths. Add symbols and your own characters (such as accented letters, quotes or emoji) through the extra characters box to check that your system stores and displays them correctly. Testing with realistic random input catches bugs that neat, hand-typed test data often misses.

Choosing length and characters together

A practical rule: decide how much strength you need, then pick the shortest length that reaches it with the characters your system allows. For 128 bits from letters and digits, you need 22 characters; from hex characters, 32. The random string generator shows the strength as you change the settings, so you can adjust until it's right.

A worked example

A developer needs five test API keys for a staging environment. In the random string generator, she sets the length to 16, how many to 5, and keeps A–Z, a–z and 0–9 ticked. The tool chooses from 62 characters, with a strength of 95.3 bits per key, comfortably strong.

For a café's printed loyalty cards, she generates 200 codes of 12 characters using uppercase letters and digits with "Avoid look-alikes" ticked, so customers won't confuse 0 and O when typing them. With 32 characters in the pool, each code has 60 bits of entropy, far more than needed for a code that's checked against a list.

Need more customers from Google?

This tool is free and runs in your browser. If your business also needs more leads or sales, Google Ads is where people search with their wallet out. That is the whole job of DeepRit: a PPC-only agency that sets up and runs Google Ads accounts so every click is accounted for. You keep full ownership of your account, get a written report every week, and can stop at any time. See our pricing or ask for a free audit.

Frequently asked questions

Is this random string generator secure?

Yes. It uses your browser's cryptographically secure random number generator, avoids modulo bias, and never sends the strings anywhere.

How long should a random string be?

For secret keys and tokens, aim for at least 128 bits of entropy, such as 22 characters from letters and digits. For codes people type, 8 to 12 characters is often enough if attempts are limited.

What does "avoid look-alikes" do?

It removes characters that are easy to confuse, such as O and 0, I, l and 1, and some quote marks.

Can I generate hex strings?

Yes. Untick the standard sets and enter 0123456789abcdef as extra characters.

Will the random string generator ever repeat a string?

It's possible but extremely unlikely with long strings. Use a unique check in your database for codes that must never repeat.

Is the random string generator free?

Yes. It's free, needs no sign-up, and works in your browser.

Free PPC audit

See where your ad budget leaks.

We look at your Google Ads account before the call, then walk you through what we'd fix first, in dollars. No obligation, no hard sell.

Book a free audit call 30-minute call · Free · The audit is yours to keep