CSP builder and checker
Understand a Content-Security-Policy header, or build one that fits your site.
Policy
Explained
What it does
A Content-Security-Policy tells the browser which scripts, styles, images and frames a page may load, which blocks inline and outside scripts unless you allow them. This tool explains each directive in plain words, warns about risky choices such as unsafe-inline, unsafe-eval and wildcards, and lists missing protections. You can also build a policy from simple choices and copy it as an HTTP header, a meta tag, an nginx line or an Apache line. Use it as a CSP checker or a CSP generator. Paste the header value, the whole header line, a meta tag, or an nginx or Apache line to have it explained, or build a new policy from simple choices.
How to use it
- 1Paste your policy, or switch to Build.
- 2Read the explanation and fix the warnings.
- 3Copy the result as a header, meta tag, nginx or Apache line.
Common uses
- Check a policy your site already sends for unsafe-inline or wildcards.
- Build a first policy for a new site from simple choices.
- Move a policy from a meta tag to an HTTP header or an nginx line.
- Understand a long policy that a framework or a CDN gave you.
- Prepare a Report-Only policy before you enforce it.
Questions
Is my policy sent anywhere?
No. It is read and checked in your browser.
Why is unsafe-inline a problem?
It lets any script that gets injected into the page run. A nonce or hash allows only the scripts you meant.
Will a new policy break my site?
It can. Try it as Content-Security-Policy-Report-Only first, watch the reports, then switch it on.
What is a Content-Security-Policy?
A header that tells the browser which sources a page may load scripts, styles, images and frames from. It limits the damage of injected scripts.
What does default-src 'self' mean?
Resources may only come from your own site, unless a more specific directive says otherwise.
What is a nonce in a CSP?
A random value that your server makes for every response. Only script tags with the same value may run.
Should I use a meta tag or a header?
A header, if you can. A meta tag ignores some directives.