CSP Header Generator

Build Content Security Policy headers visually — configure directives, sources, and export as HTTP header or meta tag

default-srcFallback for other directives
script-srcJavaScript sources
style-srcCSS stylesheet sources
img-srcImage sources
font-srcWeb font sources
connect-srcXHR, WebSocket, fetch sources
media-srcAudio and video sources
object-srcPlugin sources (Flash, etc.)
frame-srciframe sources
worker-srcWeb Worker sources
form-actionForm submission targets
base-uriBase element URLs
frame-ancestorsWho can embed this page

Additional Options

Generated Policy

HTTP HeaderContent-Security-Policy: default-src 'self'
HTML Meta Tag<meta http-equiv="Content-Security-Policy" content="default-src 'self'">

CSP Header Generator

Build Content Security Policy headers visually — configure directives, sources, and export as HTTP header or meta tag

Features

  • Visual builder for all major CSP directives
  • Toggle source values with one click
  • Add custom domains per directive
  • Strict security preset with one click
  • Export as HTTP header or HTML meta tag
  • upgrade-insecure-requests and block-all-mixed-content support
  • 100% client-side — no data sent to servers

How to use

  1. Configure each directive by clicking source values.
  2. Add custom domains in the text field for each directive.
  3. Enable additional options like upgrade-insecure-requests.
  4. Copy the generated HTTP header or meta tag.

Tips & Best Practices

  • Start with a strict policy and loosen it as needed.
  • Always set object-src to 'none' unless you need plugins.
  • Test your CSP in report-only mode before enforcing it.

FAQ

What is Content Security Policy?

CSP is an HTTP header that helps prevent XSS attacks by controlling which resources a browser is allowed to load for a page.

What does 'self' mean in CSP?

'self' allows resources from the same origin (same scheme, host, and port) as the page itself.

Should I use upgrade-insecure-requests?

Yes, if your site uses HTTPS. It instructs the browser to automatically upgrade HTTP requests to HTTPS.