64-Character Base64 JWT Secret Generator
A 64-character Base64 secret is the standard shape for a JWT signing key in JavaScript and TypeScript backends. Because Base64 packs 6 bits into every character, this generator draws 48 raw random bytes from the Web Crypto API and encodes them URL-safely before trimming to exactly 64 characters. At 64 characters it supplies roughly 384 bits of entropy, positioning it in the "comfortable" tier for HMAC-based JWT signing (HS256 / HS384).
Generating…
Why 64 characters?
64 characters roughly doubles the 32-character floor, absorbing any entropy loss from a smaller alphabet (like UUID's hex-only character set) while still being short enough to read at a glance in a .env file.
Storage & performance: Still well under SHA-256's 64-byte block size, so HMAC computes the key schedule in a single pass with no extra hashing overhead.
Most JWT libraries accept the Base64 string as-is and treat it as a UTF-8/ASCII byte sequence — no decoding step is required before signing.
When to use / when to avoid
Use a 64-char Base64 secret when…
- You want headroom above the bare HS256 minimum without a bulky value.
- Your team standardizes on one secret length across HS256 and HS384 services.
- You're rotating an existing 32-char secret and want a stronger replacement.
Consider a different length when…
- Skip it if a compliance policy mandates a specific higher bit count.
- Not ideal if you're deriving several purpose-specific keys from one master secret.
Generate a 64-char Base64 secret in code
Each snippet below produces the same shape of secret as the tool above: a 64-character base64 string using each language's cryptographically secure RNG.
import crypto from "node:crypto";
const secret = crypto.randomBytes(48)
.toString("base64url")
.slice(0, 64);
console.log(secret); // 64 chars, URL-safe base64import base64, os
raw = os.urandom(48)
secret = base64.urlsafe_b64encode(raw).decode().rstrip("=")[:64]
print(secret) # 64-char base64url secretpackage main
import (
"crypto/rand"
"encoding/base64"
"fmt"
)
func main() {
raw := make([]byte, 48)
rand.Read(raw)
secret := base64.RawURLEncoding.EncodeToString(raw)[:64]
fmt.Println(secret) // 64-char base64url secret
}import java.security.SecureRandom;
import java.util.Base64;
byte[] raw = new byte[48];
new SecureRandom().nextBytes(raw);
String secret = Base64.getUrlEncoder().withoutPadding()
.encodeToString(raw).substring(0, 64);
System.out.println(secret); // 64-char base64url secretSecurity notes
- Generated locally with crypto.getRandomValues — nothing is sent to a server, logged, or cached.
- Regenerate before first use in production; treat any secret shown on shared screens as compromised.
- Store it in a secrets manager or git-ignored .env file, never in source control or client-side code.
- Rotate on a schedule and support at least one overlapping "next" secret to allow zero-downtime rotation.
FAQ
Why does this generator produce 64-character Base64 strings specifically?
64 characters roughly doubles the 32-character floor, absorbing any entropy loss from a smaller alphabet (like UUID's hex-only character set) while still being short enough to read at a glance in a .env file. The exact length is fixed at 64 so the output is deterministic to copy into configuration without manual trimming.
How many bits of entropy does a 64-character Base64 secret carry?
A–Z, a–z, 0–9, -, _ (64-symbol alphabet, padding stripped) yields about 6 bits per character, so 64 characters work out to roughly 384 bits of entropy — well above the 256-bit floor commonly cited for HMAC-SHA256 keys.
Which JWT algorithm should I pair with a 64-char Base64 secret?
HS256 / HS384. Double the HS256 minimum, giving headroom for HS384 (384-bit output) without over-provisioning.
Base64 vs. other formats at 64 characters — which should I pick?
URL-safe Base64 encoding is the most common format for HS256/HS384/HS512 JWT signing keys stored in environment variables. Most JWT libraries accept the Base64 string as-is and treat it as a UTF-8/ASCII byte sequence — no decoding step is required before signing. Pick a different format only if your framework or secrets manager has a stated preference.
Does the 64-character length affect signing or verification performance?
Still well under SHA-256's 64-byte block size, so HMAC computes the key schedule in a single pass with no extra hashing overhead.
Where should I store a 64-character Base64 JWT secret?
Use a secrets manager (Doppler, AWS Secrets Manager, GCP Secret Manager, HashiCorp Vault, 1Password) or a git-ignored .env file. Never commit it to source control, and rotate it on a schedule appropriate for HS256 / HS384.
Is this 64-char Base64 secret generated securely?
Yes — it's produced entirely in your browser with the Web Crypto API's crypto.getRandomValues, a cryptographically secure PRNG. No network request is made and the value is never transmitted or logged.
Can I reuse this Base64 secret for something other than JWTs?
Yes. A 64-character Base64 string is a general-purpose high-entropy secret — it also works as an API key, session-encryption key, or CSRF token secret needing around 384 bits of randomness.
Related generators & tools
Recent articles
Guides on JWT secrets, signing algorithms, and token security.