CSP Generator
Create robust Content Security Policies (CSP) to defend your web application from cross-site scripting (XSS) and other code-injection attacks.
Generated CSP Policy
default-src 'self';
<meta http-equiv="Content-Security-Policy" content="...">
Pro-Tip
Always start with default-src 'self'. This denies everything unless explicitly allowed by other directives.
Understanding Directives
'self'
Allows loading resources from the same origin (same protocol, host, and port).
'unsafe-inline'
Allows the use of inline resources, such as inline <script> elements, attributes, and <style> elements.
upgrade-insecure-requests
Instructs browsers to treat all of a site's insecure URLs (those over HTTP) as though they have been replaced with secure URLs (over HTTPS).