InstrumentsCSP Header Builder
CSP Header Builder
Build a Content-Security-Policy string from a directive list, with header and meta output and warnings for unsafe values.
CSP Header Builder
- frame-ancestors is left out of the meta output. Browsers ignore frame-ancestors when a policy comes from a meta element, so send it as an HTTP response header to have any effect.
default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests
Send this as the Content-Security-Policy HTTP response header. It keeps every directive.
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'self'; base-uri 'none'; form-action 'self'; upgrade-insecure-requests">
For pages without access to response headers. Browsers ignore frame-ancestors in a meta element, so it is left out.
FAQ
Does this tool test that my site works with the policy?
No. It builds the policy text, checks the syntax, and lists the warnings described on the page. It does not load your site. Test the policy in a browser, with the console open, before you ship it.
Why is frame-ancestors missing from the meta output?
Browsers ignore frame-ancestors when a policy is delivered by a meta element. The header output keeps every directive, so send that header if you need frame-ancestors.
Can I add nonce or hash sources?
Not in this version. Sources must be keywords from a fixed list, scheme sources such as https:, or host sources. A nonce or hash source is rejected, so add it by hand and test it in the browser.
Related tutorials
§04Toolbox
Related tools
Personalize your path
Choose your experience level once.
Next Step
Build fundamentals after each tool run so you can apply concepts with confidence.