Generate a CSRF token plus the exact Set-Cookie line, hidden input, meta tag and request header for synchronizer or double-submit setups.
A random string is the easy half of CSRF protection. The half that breaks in production is everything around it: which cookie attributes to set, whether the browser is allowed to read that cookie back, and what the server compares against when the form arrives. CSRF Token Generator draws the token and then writes out the wiring it needs, matched to the pattern you choose.
Three patterns are offered, because each one stores the token somewhere different. A synchronizer token lives in the server session and issues no cookie of its own. A double-submit cookie is deliberately readable by JavaScript, since the page has to echo the value back. A signed double-submit keeps the bare token in the cookie and appends an HMAC-SHA-256 signature to the submitted copy, which is what stops a compromised subdomain from writing a cookie and a matching form field that agree with each other.
Defaults land on the common safe case: 32 bytes of entropy, Base64URL output, one token per session, cookie csrf_token, field _csrf, and the header X-CSRF-Token. Change any of the three names and every output line below updates with it.
Set-Cookie line is replaced by a note telling you to store the value against the session record instead.Max-Age entirely and disables the lifetime slider, because a token meant to live for one form render has no business outliving the tab.Max-Age attribute is omitted, producing a session cookie that dies when the browser closes.csrf token with a space produces the message “Cookie name must be an RFC 6265 token — no spaces, commas, semicolons or equals signs.” and the Generate button is disabled until you fix it.SameSite cookies. Tokens and cookie policy cover different gaps, and modern guidance treats them as layers rather than alternatives.Bytes come from crypto.getRandomValues and signatures from the WebCrypto HMAC implementation, both running inside this tab. No value is logged, transmitted or kept after you navigate away.
Random bytes come from crypto.getRandomValues and the signature from WebCrypto HMAC-SHA-256, both inside this tab. Nothing is uploaded, and no value shown here is stored or reused after you leave.
The token is sent as a cookie and echoed back in the form or header. The server only checks that the two match.
256 bits of entropy, 43 characters once encoded.
Base64URL is shorter and cookie-safe; hex is longer but survives careless logging and shell quoting.
One token for the whole session. Simple, and it survives the back button and parallel tabs.
0 drops Max-Age entirely, so the cookie dies when the browser closes.
Useful for seeding a test fixture with distinct tokens. Wiring is shown for the first.
Pick a pattern and press Generate. You get the token itself plus the exact Set-Cookie line, hidden input, meta tag and request header that pattern needs.
SameSite cookies — generating one here does not protect anything on its own.