Skip to content

Random String Generator

Mode
Characters
Generated value —
Entropy (bits)
—
Characters to choose from
—

Pick a length and a character set and the generator draws each character at random from your browser's cryptographic source. A 32-character string of letters and digits has 62 choices per position, so it holds 32 × log₂(62) ≈ 190.5 bits. Serial mode builds codes in blocks, such as INV-7KQ4-M9XD.

About this tool

Developers need throwaway tokens, test IDs, salts and API keys; shops and makers need serial numbers to print on labels or licence keys. This page covers both. In Random string mode you set the length, choose letters and digits, letters only, hexadecimal or digits, and can add 24 punctuation marks. Serial number mode writes codes in hyphen-separated blocks from a 32-character alphabet of capitals and digits that leaves out I, O, 0 and 1, so a code read off a box or typed from a sticker is not misread. Every result lists its entropy in bits, which tells you how many codes exist before repeats become likely. The values are random, not sequential: if your records need serials that count up (0001, 0002…), a spreadsheet fill series is the better fit.

How to use it

  1. Choose a mode

    Random string for tokens and keys; Serial number for blocked product or licence codes.

  2. Set the shape

    Give a length and character set, or a prefix, the number of blocks and characters per block.

  3. Copy what you need

    The first value is the headline; each row of the list below has its own copy button.

Examples

32 letters and digits

Mode
Random string
Length
32
How many
5
Characters
Letters + digits
Add special characters (!@#…)
No

Result Generated value: mAg88Rlsa9ceIZPJeEYvRLCakxSMohvL
Entropy (bits): 190.5
Characters to choose from: 62

  1. Pool = 62 characters (alnum)
  2. Entropy = 32 × log₂(62) = 190.5 bits

A 32-character token from 62 symbols carries about 190 bits, enough for API keys and session IDs.

Four blocks of five, no prefix

Mode
Serial number
Prefix
Blocks
4
Characters per block
5
How many
3

Result Generated value: 7LHCH-SC9VY-2MZ6S-ZPRZ7
Entropy (bits): 100
Characters to choose from: 32

  1. Random part = 4 groups × 5 characters = 20 characters from 32 (A–Z and 2–9 without I, O)
  2. Entropy = 20 × log₂(32) = 100 bits

A product-key style code such as ABCDE-FGH23-… with 100 bits of randomness, so two codes will in practice never collide.

INV prefix, two blocks of four

Mode
Serial number
Prefix
INV
Blocks
2
Characters per block
4
How many
10

Result Generated value: INV-Y2HV-CUZQ
Entropy (bits): 40
Characters to choose from: 32

  1. Random part = 2 groups × 4 characters = 8 characters from 32 (A–Z and 2–9 without I, O)
  2. Entropy = 8 × log₂(32) = 40 bits

Shorter codes for stock labels: eight random characters give 40 bits, about a trillion possible codes per prefix.

How it is calculated

entropy (bits) = random characters × log₂(alphabet size)

random characters
length in Random mode; blocks × characters per block in Serial mode (the prefix adds none)
alphabet size
62 for letters + digits, 52 letters, 16 hex, 10 digits, plus 24 with special characters; 32 for serials

Every character is an independent uniform draw from the alphabet, using crypto.getRandomValues in the browser. Because 16 = 2⁴ and 32 = 2⁵, a hex character carries exactly 4 bits and a serial character exactly 5 bits. By the birthday bound, repeats become likely only after about 2^(bits ÷ 2) values, so 100-bit serials will not collide in any realistic run.

Sources

Use from code or an AI agent Free API · MCP

The same calculation is a free JSON API. No key needed. The answer is in result.stats.primary.

curl -X POST https://api.tools-directory.workers.dev/v1/tools/random-string-generator \
  -H 'Content-Type: application/json' \
  -d '{"inputs":{"mode":"random","length":32,"count":5,"charset":"alnum","symbols":false}}'

When not to use it

  • If serials must run in order for audits or invoices, use a counter rather than random codes.
  • A barcode needs a symbology such as Code 128; this page makes the text, not the bars.

Common mistakes

  • Using digits-only strings for secrets: 16 digits hold only 53 bits.
  • Pasting strings with special characters into URLs or CSV files without escaping them.
  • Choosing very short serial blocks for large batches, which raises the chance of duplicate codes.

Frequently asked questions

How do I make serial numbers for my products?

Switch to Serial number mode, type a prefix such as your product line code, and set the blocks. Four blocks of five give codes like PRD-ABCDE-FGH23-… with 100 bits of randomness, so even millions of labels will not repeat. Copy the list from the table.

Can I generate a random string with special characters?

Yes. Tick Add special characters and 24 marks such as ! @ # $ % and brackets join the alphabet. With letters and digits that makes 86 choices per position, so 16 characters hold about 102.8 bits.

How do I get a random string of 32 characters?

Set Length to 32. With letters and digits you get about 190.5 bits; with hex you get exactly 128 bits, the same size as a 128-bit key written out in hex.

How do I generate a random string in Python?

Use the secrets module: ''.join(secrets.choice(string.asciiletters + string.digits) for in range(32)), or secrets.token_hex(16) for 32 hex characters. Avoid the random module for anything secret, because its Mersenne Twister output can be predicted.

How do I generate a random string in JavaScript?

In browsers and Node, fill a Uint32Array with crypto.getRandomValues and map each number onto your alphabet; that is what this page does. Math.random is not cryptographically secure and should not create tokens or keys.

How do I generate a random string in Java?

Create a java.security.SecureRandom and pick characters with nextInt(alphabet.length()) in a StringBuilder loop. java.util.Random uses a 48-bit seed and is predictable, so keep it out of anything used as a secret.

Can I make serial numbers in Excel?

For counting serials, type the first number and drag the fill handle, or use =SEQUENCE(100). For random codes, generate them here and paste the copied list into a column; Excel's RANDBETWEEN cannot easily mix letters and digits in blocks.

Is a random string generator safe for passwords?

The draws come from the browser's cryptographic source and nothing is sent anywhere, so the strings are fit for passwords. Aim for 75 bits or more, for example 13 characters of letters and digits.

Cite this tool

Using this tool in an assignment, article or report? Copy a citation, or a link for your website.

APA

Tools Directory Editorial Team. (2026, December 1). Random String Generator. Tools Directory. Retrieved December 4, 2026, from https://directory.milunir.com/developer-tools/passwords-and-hashes/random-string-generator/

MLA

Tools Directory Editorial Team. “Random String Generator.” Tools Directory, 1 Dec. 2026, https://directory.milunir.com/developer-tools/passwords-and-hashes/random-string-generator/. Accessed 4 Dec. 2026.

Chicago

Tools Directory Editorial Team. “Random String Generator.” Tools Directory. Last modified December 1, 2026. Accessed December 4, 2026. https://directory.milunir.com/developer-tools/passwords-and-hashes/random-string-generator/.

Link<a href="https://directory.milunir.com/developer-tools/passwords-and-hashes/random-string-generator/">Random String Generator – Tools Directory</a>