CSP Builder
Build Content-Security-Policy headers visually
Presets
Directives
Default fallback for other directives
Controls allowed JavaScript sources
Controls allowed CSS sources
Controls allowed image sources
Controls allowed font sources
Controls allowed fetch/XHR/WebSocket targets
Controls allowed iframe sources
Controls allowed plugin sources (Flash, etc.)
Restricts URLs for <base> element
Restricts form submission targets
Controls who can embed this page
Upgrade HTTP to HTTPS automatically
Options
When enabled, violations are reported but not blocked. Useful for testing.
Generated CSP Header
Content-Security-Policy: default-src 'self'Implementation Examples
add_header Content-Security-Policy "default-src 'self'";
Header set Content-Security-Policy "default-src 'self'"
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">
CSP Builder Guide
Learn how to create Content-Security-Policy headers to protect your website
What is Content-Security-Policy?
Content-Security-Policy (CSP) is an HTTP response header that helps prevent cross-site scripting (XSS), clickjacking, and other code injection attacks. It allows you to specify which sources of content are allowed to be loaded on your website, giving you fine-grained control over scripts, styles, images, and other resources.
How to Use
- Choose a preset (Strict, Moderate, or Relaxed) as a starting point
- Enable and configure individual directives based on your needs
- Review security warnings and adjust settings accordingly
- Copy the generated header and add it to your web server configuration