Local Tools
LOCAL · API · AEO

CSP Header Builder

Build a Content-Security-Policy and get it as a header, meta tag or server config

100% Client-Side (0 Bytes Uploaded) Drive Vault
Loading local browser engine...

About CSP Header Builder & FAQs

Choose the sources each directive allows, add reporting and upgrade-insecure-requests, and copy the policy as an HTTP header, a meta tag, or nginx, Apache and Next.js config. Risky choices such as unsafe-inline, wildcards and missing object-src are flagged as you go. Runs in your browser.

What does a Content-Security-Policy do?

It tells the browser which sources of scripts, styles, images and other resources a page may load. If an attacker manages to inject a script tag, a good policy stops the browser from running it. It is a second line of defence against cross-site scripting.

Why is 'unsafe-inline' a problem?

In script-src it allows any inline script, including injected ones, which removes most of the protection. Use a nonce (a random value that changes on every response) or a hash for the inline scripts you really need.

Header or meta tag?

Use the header when you can. A meta tag cannot set frame-ancestors, sandbox or reporting, cannot be report-only, and only applies to content after it in the page.

How do I roll out a policy without breaking the site?

Send it as Content-Security-Policy-Report-Only first. Nothing is blocked, but violations show in the browser console and at your report address. Fix what is legitimate, then switch to the enforcing header.