CSP Generator
Generate secure Content Security Policy headers for your Next.js application. Protect against XSS attacks with smart presets for popular services.
Configure Your Security Policy
Select presets for common services or customize individual directives to generate your CSP header configuration.
Quick Config
Choose a security level to automatically configure all directives.🔒Strict (Production)
Maximum security. Block everything except same-origin.⚖️Recommended (Balanced)
Good balance between security and functionality.🔓Permissive (Development)
Relaxed policy for development. Not recommended for production.✏️Custom
Start fresh or keep your current configuration.Smart Defaults
Automatically append trusted domains for common services.Google Analytics 4
Allows Google Tag Manager and GA4 scripts.Vercel Analytics
Required for Vercel Web Vitals tracking.Stripe JS
For Stripe Elements and payment processing.Google Fonts
Allows loading fonts from Google Fonts.Cloudflare CDN
Common CDN for libraries and assets.YouTube Embeds
Allows embedding YouTube videos.Directives Configuration
default-src
script-src
style-src
img-src
connect-src
font-src
frame-src
object-src
base-uri
frame-ancestors
Policy Preview
default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; font-src 'self'; frame-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none';
Understanding Content Security Policy
Key concepts for protecting your application
XSS Protection
Directive Control
Smart Presets
Frequently Asked Questions
Common questions about Content Security Policy