CSP Generator & Evaluator.
Check a Content-Security-Policy for XSS bypasses, or build one from a preset with ready-to-paste server snippets.
Runs in your browserAbout CSP Generator & Evaluator
The CSP Generator & Evaluator helps you write a Content-Security-Policy that actually stops cross-site scripting. In evaluate mode, paste the header from your site and every directive is checked against the mistakes that make a policy easy to bypass: 'unsafe-inline' without a nonce or hash, 'unsafe-eval', wildcards and bare https: in script-src, hosts such as cdnjs.cloudflare.com or www.google.com that serve JSONP or AngularJS and are known bypasses, keywords written without quotes (self instead of 'self'), short nonces, malformed hashes, and missing object-src, base-uri and frame-ancestors. Findings are sorted by severity and each one says why it matters. For example, script-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com gets a high finding for 'unsafe-inline', a medium one for the CDN, and a high one because object-src is missing. In generate mode, start from a starter allowlist or Google's recommended strict policy ('nonce-…' plus 'strict-dynamic'), override any directive, add a report URI, and copy the result as an HTTP header, a Report-Only header, nginx add_header, Apache Header set or an HTML meta tag. A frequent error is putting frame-ancestors or report-uri in a meta tag, where browsers ignore them; the snippet leaves them out. Roll out with Report-Only first. Everything is evaluated in your browser.
How to Use
- Choose evaluate and paste your current policy, or choose generate and pick a preset.
- Read the findings table, starting with the high-severity rows.
- Copy the normalized policy or a server snippet and deploy it as Report-Only first.
Frequently Asked Questions
What is a strict CSP?
A policy that trusts scripts by nonce or hash instead of by host, usually script-src 'nonce-RANDOM' 'strict-dynamic'; object-src 'none'; base-uri 'none'. It avoids the host allowlist bypasses that most CSPs suffer from.
Why is 'unsafe-inline' only "info" in some policies?
When a nonce or hash is present, CSP Level 2+ browsers ignore 'unsafe-inline'. It is kept only so very old browsers still run the page.
Where do I get the nonce?
Your server must generate a new random value (at least 128 bits, Base64) for every response and put it in both the header and each script tag. The {RANDOM} placeholder in the preset must be replaced.
Is my policy sent to a server?
No. Parsing and evaluation run in your browser, and the page makes no network requests while you use it.
Related Tools
Generate Subresource Integrity hashes and ready-to-paste script or link tags for CDN files.
Decode PEM or DER certificates to see subject, issuer, validity, SANs, key and extensions.
Encode and decode URL components.
Encode and decode HTML entities.
Decode, inspect, and verify JSON Web Tokens.
Hash and verify passwords with bcrypt or Argon2.