CSP Builder

Build a Content-Security-Policy header from individual directives, locally in your browser.

Enter space-separated sources for each directive you want to set (e.g. 'self' https://example.com). Leave a directive blank to omit it.

Starting point only

A correct CSP depends on your actual page's scripts, styles, images, and third-party embeds โ€” test any policy with Content-Security-Policy-Report-Only before enforcing it, since an overly strict policy can silently break page functionality.

Share on LinkedInShare on X
Link to this tool

Copy this HTML to cite this tool from your own site or article.

About CSP Builder

CSP Builder assembles a Content-Security-Policy header value from individual directives you fill in, locally in your browser.

How to use CSP Builder

  1. Enter space-separated sources for each directive you want to include (e.g. 'self' https://example.com).
  2. Leave any directive blank to omit it from the policy.
  3. Click Build policy.
  4. Copy the resulting header value or HTML meta tag.

Examples

default-src 'self', img-src 'self' data: Result: default-src 'self'; img-src 'self' data:;

FAQ

Will this policy work for every site automatically?

No. A correct CSP depends on your page's actual scripts, styles, and embeds โ€” test it against your real site before enforcing it.

What's the difference between the header and the meta tag output?

Both express the same policy. The HTTP header is generally preferred since some directives (like frame-ancestors) are ignored when set via a meta tag.