Build Content Security Policy headers visually. Configure script-src, style-src, img-src, and more with a UI — get the header string, meta tag, and .htaccess output instantly. Free, no signup.
CSP Generator — Build Content Security Policy Headers Without the Syntax
Content Security Policy headers are powerful but complex to write by hand. A single typo — a missing apostrophe around 'self', a wrong directive name, a missing semicolon — can leave your site unprotected or break legitimate content loading. This generator provides a visual interface that guarantees syntactically correct output every time.
Deploying CSP Safely
Never deploy a new CSP directly to production in enforcement mode without testing. The recommended workflow: first, deploy in report-only mode with a reporting endpoint. Collect violation reports for at least a week to identify all the legitimate sources your site loads. Update your policy to allow those sources. Then switch from Content-Security-Policy-Report-Only to Content-Security-Policy in enforcement mode.
The Strictest Possible CSP
The "Strict CSP" pattern recommended by Google uses: default-src 'none' (block everything by default), with explicit allowlists for each resource type, using nonces for inline scripts instead of 'unsafe-inline', and strict-dynamic to allow dynamically loaded scripts. This approach eliminates XSS entirely for pages that implement it correctly, and is used by Google, GitHub, and other high-security sites.