CSP Header Generator

Visually build a Content-Security-Policy HTTP header. Enable directives like script-src, style-src, and img-src with checkboxes. Copy the generated header string.

Used 5.3K times today

default-srcFallback for all resource types
Common: 'self' 'none' 'unsafe-inline' 'unsafe-eval' https: data: *.example.com
script-srcJavaScript sources
Common: 'self' 'none' 'unsafe-inline' 'unsafe-eval' https: data: *.example.com
style-srcCSS sources
Common: 'self' 'none' 'unsafe-inline' 'unsafe-eval' https: data: *.example.com
img-srcImage sources
Common: 'self' 'none' 'unsafe-inline' 'unsafe-eval' https: data: *.example.com
font-srcFont sources
connect-srcAJAX, WebSocket sources
media-srcAudio and video sources
object-srcPlugin sources (Flash, etc.)
frame-srciframe sources
worker-srcWeb Worker sources
form-actionForm submission targets
upgrade-insecure-requestsUpgrade HTTP to HTTPS
Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:

How to Use CSP Header Generator

  1. 1

    Enable directives

    Check the directives you want to include such as default-src, script-src, and style-src.

  2. 2

    Set source values

    Enter allowed sources for each directive, such as self, https:, or specific domains.

  3. 3

    Copy the header

    Copy the generated Content-Security-Policy header string for your web server configuration.

Frequently Asked Questions

What is a Content Security Policy?
A CSP is an HTTP response header that restricts which resources a browser can load, significantly reducing the risk of XSS attacks.
Should I start with strict-dynamic?
For modern apps, strict-dynamic with nonces is the most secure approach. For simpler sites, a basic default-src self policy is a good starting point.

Embed This Tool

Add this tool to your website for free. Just copy and paste the code below:

<iframe src="https://utilko.com/embed/csp-header-generator/" width="100%" height="500" frameborder="0" title="CSP Header Generator"></iframe>

About CSP Header Generator

The CSP Header Generator on Utilko provides a visual builder for Content-Security-Policy headers — one of the most effective HTTP security measures to prevent cross-site scripting attacks.

More Category Tools