Random String Generator
Your secret
Generating in your browser…
Generated on your device with the Web Crypto API. Never sent or stored.
Prefer the terminal?
- OpenSSL
openssl rand -hex 32
How to use your random string
Copy the value above and add it to wherever you need it: a config file, a test fixture or a database seed. Keep it out of source control: commit an .env.example with an empty value instead, and set the real value in your hosting provider's environment settings or a secrets manager.
Hex uses only 0–9 and a–f, so it is safe everywhere but long. Base64 packs the same randomness into fewer characters, and base64url swaps + and / for - and _ so the value is safe in URLs, file names and cookies. The number of bytes sets the strength: 16 bytes is 128 bits, 32 bytes is 256 bits.
Is it safe to generate secrets in a browser?
Only if the secret is created locally, which is how this page works. The value comes from crypto.getRandomValues, the same cryptographically secure source browsers use for TLS keys, and it never leaves your device: there is no network request, log or analytics event that includes it.
If you prefer the command line, the commands on this page produce an equivalent secret on your own machine. Either way, use a different secret for development, staging and production, and rotate it straight away if it ever appears in a log, a screenshot or a public repository.
Frequently asked questions
Is Math.random() good enough?
Not for anything secret. Use crypto.getRandomValues (browser) or crypto.randomBytes (Node), which this tool uses.