Secure CSP Nonce Generator
Generate a 128-bit base64 random nonce for Content-Security-Policy with sample header and <script nonce> attribute.
—
Getting a CSP nonce right in production
You want unsafe-inline out of your script-src, but the page still carries a handful of inline scripts you cannot move today. The standard answer is a nonce: a random value that appears both in the header and on the tag, so only the scripts you marked are allowed to run. What usually stalls the work is the exact shape of the header and how much randomness is enough.
The value comes from the browser crypto.getRandomValues, a cryptographic generator rather than Math.random. The default is 16 bytes, 128 bits, which encode to 24 base64 characters. The field accepts 16 to 64 bytes and quietly clamps anything outside that window. The output shows the finished header and the script tag together, and both must carry the identical value or the browser blocks the script.
Here is the warning that matters most: a nonce copied off a web page and pasted into a static template protects nothing at all. It has to be drawn fresh for every HTTP response, on the server, and injected into the header and the HTML of that same request. Use this box to check the shape, build a curl test or write documentation. Note too that once a nonce is present, modern browsers ignore unsafe-inline.
Frequently asked questions
Can I reuse one nonce across pages?
Is 128 bits of entropy enough?
Do I still need unsafe-inline alongside the nonce?
Related Tools
Secure Token Generator
Generate cryptographically secure random tokens (alphanumeric, hex or base64) in your browser. Ideal for API keys, secrets, passwords and unique IDs.
Trusted Types Policy Builder
Generate CSP require-trusted-types-for and trusted-types directives with policy names — a modern anti-XSS mitigation.
Content-Security-Policy Builder
Build a Content-Security-Policy header by adding directives (default-src, script-src, img-src, frame-ancestors) with predefined sources.
Basic CSP Evaluator
Evaluates a Content-Security-Policy directive reporting unsafe-inline, unsafe-eval or wildcard issues.
Encrypt Text
Apply classic ciphers (Caesar, ROT13, Atbash) or Base64. Useful for puzzles, CTFs and testing — do not use for real security.
SAML Response Base64 Decoder
Decodes and indents base64-encoded SAMLResponse XML for inspection — useful for SSO debugging.