Random String Generator
Generate random strings from letters, numbers, hex or your own characters. Choose the length and how many, using a cryptographic random source.
Generate random strings from letters, numbers, hex or your own characters. Choose the length and how many, using a cryptographic random source.
Random strings are used for tokens, IDs, test data and temporary keys. This tool builds them from the character set you choose using your browser's cryptographic random source.
You can use letters, numbers, hex, a URL-safe set, or your own characters.
The strength of a random string depends on its length and the size of the character set, measured as entropy in bits. Each character from a set of N symbols adds log2 of N bits, so a 62 character set of letters and digits gives about 5.95 bits per character, and hex gives exactly 4. A 16 character alphanumeric string carries about 95 bits, which is far beyond practical guessing. Using fewer symbols needs a longer string to reach the same strength, so 32 hex characters give 128 bits. The source of randomness matters just as much as the length.
Selecting characters needs care to avoid bias. If a generator maps a random byte from 0 to 255 onto 62 characters using modulo, some characters appear slightly more often because 256 does not divide evenly by 62. Good implementations reject the uneven range of values and draw again. URL-safe sets avoid characters that need percent encoding, and Base64URL uses the hyphen and underscore for this reason. Generated strings are random, not guaranteed unique, so for database keys rely on a uniqueness constraint or a proper UUID scheme. Ambiguous characters such as O and 0 can cause trouble for strings that people read aloud.
The randomness is cryptographic. For long-lived production secrets, generate them on the system that will use them.
Letters, digits, hyphen and underscore, which can appear in URLs without encoding.
At least 16 characters from a large set for casual use, and more for security tokens.
No. They are generated in your browser.
It is possible but extremely unlikely for long strings from a large set. For identifiers that must never collide, enforce uniqueness in your database or use a standard UUID.
Multiply the length by log base 2 of the character set size. For example, 20 characters from 62 symbols gives about 119 bits, and 20 hex characters gives 80 bits.