Fallback for most directives
JavaScript sources
CSS stylesheet sources
Image sources
Font sources
XHR/fetch/WebSocket
iframe/frame sources
About CSP Header Generator
CSP Header Generator helps you build a valid Content Security Policy header for your website by selecting trusted sources for scripts, styles, images, fonts, and other resource types through a guided interface. A properly configured CSP is one of the most effective defenses against cross-site scripting (XSS) attacks.
How to Use CSP Header Generator
- 1
Select your resource directives
Use the checkboxes and input fields to specify trusted sources for scripts (script-src), styles (style-src), images (img-src), fonts, and other directives.
- 2
Review the generated header
The tool assembles your selections into a valid Content-Security-Policy header string that you can preview and test.
- 3
Copy and deploy the header
Copy the generated header string and add it to your web server configuration, CDN settings, or HTML meta tag.
Common Use Cases
- Hardening a new website against XSS attacks by implementing a CSP from launch
- Developers updating an existing CSP to allow new trusted third-party resources
- Security engineers generating CSP headers as part of a security audit remediation
- Learning which directives to configure for a specific tech stack
Frequently Asked Questions
What is a Content Security Policy?
Will adding a strict CSP break my website?
How do I add the CSP header to my website?
Related Tools
Meta Tag Generator
Generate HTML meta tags for SEO, social sharing, and more.
.htaccess Generator
Generate Apache .htaccess rules for redirects, security, and caching.
SSL Certificate Checker
Check SSL certificate details, expiry date, and chain validity.
Hash Generator
Generate MD5, SHA-1, and SHA-256 hashes from any input text.
Text Encryption/Decryption
Encrypt and decrypt text using AES encryption.
ROT13 Encoder
Encode and decode text using the ROT13 substitution cipher.