What the Secure Random String does
The Secure Random String tool makes random text of any length from 1 to 1,024 characters, using your browser’s cryptographic random generator. Pick a character set, such as letters and numbers, hex, URL-safe Base64 or numbers only, or type your own list of characters. Add an optional prefix like key_ and make up to 100 at a time. The tool shows how many bits of randomness each string has.
How to use it
- Choose the characters to use, or pick My own characters and type them.
- Set the length and an optional prefix.
- Choose how many and press Generate.
- Copy one string, copy them all, or download a text file.
Example
A 32-character string of letters and numbers has about 191 bits of randomness, far more than needed. A 32-character hex string has exactly 128 bits, a common size for tokens and keys, and 22 characters of URL-safe Base64 give 132 bits.
How long should a secret be?
For API keys, session tokens, webhook secrets and password reset links, aim for at least 128 bits. Every character from a set of 62 adds about 5.95 bits; hex adds 4 bits each, URL-safe Base64 adds 6.
The characters are chosen without bias: each is equally likely, because values that would favour some characters are thrown away and drawn again. Simple methods that use Math.random or the remainder of a division can be predictable or uneven.
Choosing a character set
Use hex or lowercase letters and numbers where case may be lost, such as in DNS names. URL-safe Base64 fits in links without encoding. Avoid symbols in values that will be pasted into shells or config files.
Questions people ask
Can I use these as passwords?
Yes. A 20-character string from the letters, numbers and symbols set is very strong. A password manager can store it for you.
Are the strings sent anywhere?
No. They are made in your browser and never leave it.
What is the prefix for?
Prefixes such as sk_ or key_ make secrets easy to recognise in code and logs, and help secret scanners spot leaks.