CSP Generator

Generate a Content-Security-Policy header or meta tag with custom directives.

Directives:

Suggested Tools

About the CSP Generator

The CSP (Content Security Policy) Generator helps web developers create secure CSP headers to protect their websites from attacks like cross-site scripting (XSS) and data injection. A good CSP is a powerful security layer for any site.

Why use a CSP Generator?

How to use the tool

  1. Select which resources (scripts, styles, images, etc.) your site allows.
  2. Choose whether to use strict settings or allow specific domains.
  3. Click Generate to get your ready-to-use CSP header.
  4. Add the header to your server or meta configuration.

Example: A strict CSP may look like: Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self'