UTILS.
Private by default
🛡

CSP Header Builder

Build a Content-Security-Policy header by filling in common directives.

Your files stay on this device

Files are processed in your browser, never uploaded. The site downloads code and assets to run the tools. No accounts or trackers.

Use Download to save this tool as one HTML file for offline use.

Privacy →
— output appears here —

About this tool

Assemble a Content-Security-Policy header string from common directives prefilled with 'self'; the header is built entirely in your browser.

One box is provided for each of seven directives: default-src, script-src, style-src, img-src, font-src, connect-src and frame-src, each starting with 'self'. Each box is trimmed and its whitespace collapsed, empty boxes are skipped, and the rest are joined with a semicolon and space after "Content-Security-Policy: ".

Values are not validated: they are copied as typed, so you add the quotes around keywords like 'self' yourself. Other directives such as base-uri or frame-ancestors are not available. Copy includes the header name.

Frequently asked questions

What does 'self' mean?
The 'self' keyword allows resources only from your own origin (same scheme, host and port), a safe default for most directives.
How do I deploy the header?
Send the generated line as an HTTP response header from your server or CDN. For a <meta http-equiv> tag, use only the value after the header name.
Does the tool validate my policy?
No. It only joins what you type.
Can I test the policy here?
No. It builds the text and does not load your site or report violations.

More tools