Build a Content Security Policy header interactively — configure directives, get server config snippets
Pick the sources you allow for scripts, styles, images, frames and other resource types, and the generator assembles a valid Content-Security-Policy header. It also outputs configuration snippets you can paste into common web servers. More free security tools.
A Content-Security-Policy header is only as good as its weakest directive — a single script-src 'unsafe-inline' or a wildcard host can undo the protection the rest of the policy provides against XSS and data injection. Building one by hand means tracking which directive governs which resource type (script-src, style-src, img-src, frame-src, connect-src and more) and getting the source-list syntax exactly right.
This generator lets you pick allowed sources per resource type and assembles a syntactically valid header, along with ready-to-paste configuration snippets for common web servers. Start as restrictive as your application allows — default-src 'self' plus explicit exceptions — rather than adding broad allowances and trying to narrow them later.
Need help implementing and monitoring CSP for your web applications?
If you like this tool, Speak with OneFirewallA Content Security Policy (CSP) tells the browser which sources of scripts, styles, images and frames your page may load. A well-tuned policy is one of the strongest defences against cross-site scripting (XSS) and data injection.
Writing CSP by hand is error-prone. The generator builds a valid header from your choices and outputs snippets for Nginx, Apache or an HTML meta tag.
Start with the Content-Security-Policy-Report-Only header so violations are reported but nothing is blocked, fix what breaks, then switch to the enforcing header.
It allows any inline script to run, which removes most of CSP's protection against XSS. Nonces or hashes let specific inline scripts run safely.
Yes, for most directives. Some, such as frame-ancestors and report-uri, only work when sent as an HTTP header.
More free tools: OneFirewall Free Tools · Terms explained: Glossary