CSP (Content Security Policy) Generator
Visual rule builder to create robust Content-Security-Policy headers restricting script, style, and media sources.
default-srcFallback for all resource typesscript-srcJavaScript execution sourcesstyle-srcStylesheet sourcesimg-srcImage sourcesconnect-srcXHR/fetch/WebSocket endpointsobject-srcPlugin content (Flash, etc.)frame-ancestorsWhich pages may embed this pagereport-uriadd_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requests;" always;
# Apache (.htaccess):
Header always set Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requests;"
How to Use CSP (Content Security Policy) Generator
Toggle allowed directives (self, none, trusted CDNs, Google Fonts).
Configure script-src, style-src, and connect-src rules.
Copy the generated Content-Security-Policy header string.
CSP (Content Security Policy) Generator runs 100% client-side in your web browser. Your data, passwords, keys, and files are processed using the Web Crypto API and never transmitted to any server. Zero telemetry, zero storage, zero cloud processing.
Frequently Asked Questions
How does CSP block XSS attacks?
By restricting where scripts can load from and disabling inline eval(), browsers reject injected scripts.
Related Security Tools
SSL Certificate & Expiry Checker
Inspect SSL/TLS certificate validity, expiration date, issuer CA, SAN domains, and days remaining.
TLS Configuration Checker
Evaluate supported TLS versions (TLS 1.2, TLS 1.3), cipher suites, and obsolete protocol risks.
HTTPS & Redirect Chain Checker
Trace HTTP to HTTPS redirects, detect insecure mixed-content hops, and verify 301 permanent rules.
Security Headers Inspector
Scan web servers for critical headers: CSP, HSTS, X-Frame-Options, X-Content-Type-Options, and Referrer-Policy.
HTTP Header Analyzer
Inspect raw response headers, caching directives, server signatures, and potential information leaks.
CSP Policy Validator
Audit existing Content Security Policy strings for unsafe-inline, wildcard (*), and bypass vulnerabilities.