Content Security Policy Generator
Build a Content-Security-Policy header or meta tag from the sources you allow for scripts, styles, images, fonts, and other resources. Empty fields are left out of the policy.
1 Fill in the boxes
2 Your answer
Your answer shows here as you type.
How to use the Content Security Policy Generator
- Enter the sources allowed for each resource type, using keywords like 'self' in quotes.
- Leave a field empty to leave that directive out of the policy.
- Copy the header for your server, or the meta tag for a static HTML page.
Frequently asked questions
What is a Content Security Policy?
A Content Security Policy is an HTTP response header, or a meta tag, that tells the browser which sources a page may load scripts, styles, images, fonts, and other resources from. It helps reduce the risk of cross-site scripting.
What does default-src do?
default-src sets the fallback for any fetch directive that is not set on its own, such as script-src or img-src. Setting it to 'self' allows only resources from the same origin.
Why is frame-ancestors not in the meta tag?
frame-ancestors controls which sites may embed the page in a frame, and browsers only enforce it when it is sent as an HTTP header. It replaces the older X-Frame-Options header.
What does 'unsafe-inline' mean?
'unsafe-inline' allows inline scripts or styles written directly in the HTML. It weakens the policy, so nonces or hashes are usually a safer choice.
Wrote something with AI? Slop Monkey rewrites it so it sounds like you, and keeps your facts.