Webhook and session secret generator
Generate a random signing secret for webhook signatures, session cookies or CSRF tokens. The default, 256 bits in hex, works with almost every framework.
runs in your browser · nothing uploaded
How to use it
- Keep 256 bits unless your framework asks for something else.
- Choose hex, Base64 or Base64url, and add a prefix such as whsec_ if you want one.
- Store the secret in your environment, such as WEBHOOK_SECRET or SESSION_SECRET.
How webhook signatures work
The sender and receiver share this secret. For each request the sender computes HMAC-SHA256 of the raw request body with the secret and sends it in a header. The receiver computes the same HMAC from the body it received and compares the two with a constant-time function, such as crypto.timingSafeEqual in Node.js or hmac.compare_digest in Python.
Compute the HMAC over the raw bytes, before any JSON parsing, or a reordered key or changed whitespace will break the check. Many providers also sign a timestamp so an old request can't be replayed.
Session and CSRF secrets
Frameworks such as express-session sign the session cookie with a secret so users can't forge one. 256 random bits is plenty. Most frameworks generate CSRF tokens for you per session; if you roll your own, make each token at least 128 random bits and tie it to the session.
Questions
Is the value sent to a server?
No. It is made in your browser with JavaScript and the Web Crypto API. Nothing is uploaded, logged or stored by us. For production secrets you may still prefer to generate them on the machine that uses them; the command for that is on this page.
How random is it?
Every value comes from crypto.getRandomValues, the browser's cryptographically secure random generator, which is seeded by the operating system. Characters are picked with rejection sampling, so none is more likely than another.
How do I rotate a webhook secret?
Accept signatures made with either the old or the new secret for a short overlap, switch the sender to the new secret, then remove the old one.