How to use
Use this generator to create a strong, random key and encode it as Base64.
- Choose the key length in bytes (common: 32 for 256-bit, 64 for 512-bit).
- Select Base64 or Base64URL (recommended for JWT/URLs).
- Toggle padding (=) on/off if needed by your library.
- Click Generate, then Copy the result.
FAQ
Is this key generator cryptographically secure?
Yes, it uses crypto.getRandomValues in your browser to generate random bytes.
What key length should I use?
For most secrets, 32 bytes (256-bit) is a solid default; use 64 bytes if you want extra margin.
Base64 vs Base64URL: what’s the difference?
Base64URL replaces + and / with - and _ so the value is URL/JWT-safe.
Should I include padding (=)?
Many JWT and URL-safe uses omit padding; some libraries expect standard padded Base64, so match your target system.
Is Base64 the same as encryption?
No—Base64 is only an encoding. Anyone can decode it, so treat the key as a secret and store it securely.
Can I use this for JWT HS256/HS512 secrets?
Yes. Generate at least 32 bytes for HS256; longer is fine as long as your verifier uses the same secret bytes.
Why does the same byte length produce a longer Base64 string?
Base64 encodes every 3 bytes into 4 characters, so the text grows by about 33% (less if you remove padding).