The JWT Secret Generator creates the shared HMAC secret used to sign and verify HS256, HS384, or HS512 JSON Web Tokens, sized to the algorithm (32, 48, or 64 bytes) and formatted as a ready-to-paste JWT_SECRET= line. It differs from an API key, which identifies a caller, and from an RSA key pair, which RS256 tokens use instead of a shared secret.
Click Generate to create a JWT secretDecoding a token signed with this secret? Use the JWT Decoder.
Input
HS256, base64url
Output
JWT_SECRET=3pXFKvQ-YtHe1WaEPf__Y01EceZKGwR1EuN2Dy86Mwc (32 random bytes, 43 characters)
Input
HS512, hex
Output
35a11658d871dab501c679aa9a94a4238df2f35287663a57326b6f0a1ef8b564bc11bb704375768b9a3582e8fbeb643dbcaff3409dcef99ae6201e74c8a382ba
A JWT signed with HS256 is only as trustworthy as the secret behind it. Anyone who gets hold of that secret can mint tokens claiming to be whoever they want, so the secret needs to be long, random, and nothing a person would ever guess or reuse from somewhere else.
This generator matches the secret length to the algorithm you pick. HS256 wants 256 bits, HS384 wants 384, HS512 wants 512, and the tool handles that sizing for you rather than leaving it to guesswork. Every byte comes from `crypto.getRandomValues`, the same CSPRNG source used across every tool in this category, not a general-purpose random function that was never meant for security use.
Base64url is usually the right pick if you're dropping the secret into a `.env` file or an environment variable, since it avoids characters like `+` and `/` that sometimes cause quoting headaches in shell scripts. Hex works fine too and is a bit easier to read at a glance, though it needs more characters to carry the same amount of entropy.
One habit worth building: rotate the secret whenever a service it protects changes hands, gets redeployed with new infrastructure, or you're just not sure who's seen it. A rotated secret invalidates every token signed with the old one, which is sometimes exactly the point, and sometimes an inconvenience you'll want to plan around rather than discover in production.
More Security