CSP Generator

CSP Generator

Build Content-Security-Policy headers from common directives for production-ready deployment.

CSP Header

About the CSP Generator Online Free Tool

The CSP Generator Online Free Tool creates a Content-Security-Policy header from common directives such as default-src, script-src, style-src, img-src, connect-src, and frame-ancestors. It is a quick drafting tool for security headers.

How to Use the CSP Generator Online

  1. Enter allowed sources for each directive you want to include.
  2. Leave directives blank if they should not appear in the generated policy.
  3. Generate the CSP header.
  4. Copy the output and test it in report-only mode before enforcing it.

Choosing Options Correctly

Start with restrictive values such as 'self' and add external domains only when required. Avoid unsafe-inline unless you have a clear migration plan.

Common Use Cases

  • Draft a first CSP for a site or app.
  • Build a policy for common CDNs and asset hosts.
  • Create a header to evaluate with the CSP Evaluator.

Quick FAQ

Should I deploy the generated CSP immediately?
Use report-only testing first. CSP can break scripts, styles, images, fonts, and embeds if sources are incomplete.

Does this include every CSP directive?
No. It covers common directives for a compact workflow. Add specialized directives manually if your site needs them.

What if report-only shows violations?
Add only the sources you actually trust, retest, and switch to enforcement after the required flows still work.

Should a CSP be short?
Usually yes. A concise policy is easier to review and less likely to hide overly broad allowances.