Generate CSP header – Free Content Security Policy Generator

Learn more

Need a CSP header? Build Content Security Policy rules to prevent XSS attacks. Generate CSP headers for Nginx, Apache, or meta tags.

CSP Generator
Need a CSP header? Build Content Security Policy rules

Content Security Policy

CSP helps prevent XSS attacks by controlling which resources can be loaded. Start with a restrictive policy and relax as needed.

Configure CSP behavior

Use Content-Security-Policy-Report-Only header (for testing)

'self'
'self'
'self'
'unsafe-inline'
'self'
data:
https:
'self'
data:
https:
'self'
'none'

Best Practices

  • Start with default-src 'self' and add exceptions as needed
  • Avoid 'unsafe-inline' and 'unsafe-eval' when possible
  • Use nonce or hash for inline scripts/styles
  • Test in Report Only mode before enforcing
  • Set object-src 'none' to prevent plugin attacks
No output generated yet. Use the tool to generate content.