CSRF Token Generator
Generate cryptographically secure CSRF tokens using the Web Crypto API. Choose length and format, then copy for use in your forms.
Token Options
256
Entropy (bits)
32
Bytes
64
Characters
HTML Form Usage
Copied!
Summary
Generate cryptographically secure CSRF tokens using the Web Crypto API. Choose length and format, then copy for use in your forms.
How it works
- Select the desired token byte length: 16 (128-bit), 32 (256-bit), or 64 (512-bit).
- Choose an output format: hex, base64, or base64url (URL-safe, no padding).
- Click "Generate Token" or any option to produce a new cryptographically random token.
- The entropy in bits is calculated and displayed alongside the token.
- Click "Copy" to copy the token to your clipboard for use in your application.
Use cases
- Generate a one-time CSRF token to embed in HTML forms as a hidden field.
- Create synchronizer tokens for AJAX requests sent as custom headers.
- Produce URL-safe tokens for double-submit cookie CSRF mitigation patterns.
- Generate secure nonces for Content Security Policy (CSP) headers.
- Test CSRF protection implementations during security audits.
Frequently Asked Questions
Last updated: 2026-06-09 ·
Reviewed by Nham Vu