Random Secret Generator
Generate secure random strings based on crypto.
A cryptographically secure random secret is essential for signing JWTs, encrypting data, generating API keys, and creating session tokens. This tool uses the browser's Web Crypto API (crypto.getRandomValues) to generate high-entropy random secrets that are safe to use in production systems. All generation is done locally — your secrets are never transmitted to any server.
How to Use
- 1
Select output format
Choose between Base64 (for JWT secrets and API keys) or Hex (for cryptographic keys and checksums) output formats.
- 2
Choose the secret size
Select the byte size: 16 bytes (128-bit), 32 bytes (256-bit), 48 bytes (384-bit), or 64 bytes (512-bit). For most applications, 32 bytes is the recommended minimum.
- 3
Click Generate Secret
A new cryptographically random secret is generated instantly using the Web Crypto API. Click again to regenerate.
- 4
Copy and store securely
Copy the secret to your clipboard and store it in a secure location such as an environment variable or secrets manager.
Features
Web Crypto API
Uses browser-native crypto.getRandomValues() for cryptographically secure randomness — not Math.random().
Multiple Output Formats
Generate secrets in Base64 or Hex format depending on the requirements of your application.
Configurable Size
Choose secret length from 16 to 64 bytes to match the security requirements of your use case.
Never Leaves Your Browser
Secrets are generated and displayed entirely client-side. No network requests are made.
Frequently Asked Questions
- What makes a random secret cryptographically secure?
- A cryptographically secure random number generator (CSPRNG) produces values that are computationally unpredictable. The Web Crypto API uses the operating system's entropy sources (hardware noise, timing jitter) to generate values that cannot be predicted even with knowledge of past outputs.
- How long should my JWT secret be?
- For HMAC-SHA256 (HS256) JWT signing, use a minimum of 256 bits (32 bytes). This provides sufficient security against brute-force attacks. A 32-byte Base64 secret from this tool is ideal.
- What is the difference between Hex and Base64 output?
- Hex encoding uses characters 0-9 and a-f, producing a string twice the length of the byte count. Base64 uses A-Z, a-z, 0-9, +, /, producing a string about 1.33× the byte count. Base64 is more compact and widely used in authentication headers, while Hex is common in cryptographic checksums.
- Can I use these secrets in production?
- Yes. The secrets generated here use the same cryptographic quality as server-side secret generators. They are safe for JWT signing keys, API keys, encryption keys, and session secrets.