KitBench

Content-Security-Policy (CSP) Generator

Build strict HTTP Content-Security-Policy headers visually with directives for scripts, styles, images, frames, fonts, and reporting.

Privacy Notice: Runs locally in your browser without uploading files to external servers or requiring an account.

Interactive Browser Workspace

Loading the interactive Content-Security-Policy (CSP) Generator workspace. Enable JavaScript in your browser to run calculations and conversions locally.

How to Use Content-Security-Policy (CSP) Generator

  1. Choose a baseline preset (Strict Static, Balanced Web App, or Custom) and configure each CSP fetch directive.
  2. Review security warnings and copy the formatted `Content-Security-Policy` HTTP header or `<meta>` tag.

Methodology & Accuracy

Assembles normalized W3C CSP Level 3 directive lists and flags unsafe keywords (`unsafe-inline`, `unsafe-eval`, `*` wildcards).

Examples

  • Build a clean `default-src 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requests` policy.

Scope & Limitations

  • Test new policies using `Content-Security-Policy-Report-Only` first so legitimate scripts or analytics are not blocked unexpectedly.

Frequently Asked Questions

Why is frame-ancestors better than X-Frame-Options?

`frame-ancestors` in CSP supersedes legacy `X-Frame-Options` and supports multiple allowed parent origins.

Should I test a new Content Security Policy in Report-Only mode first?

Yes. Deploying `Content-Security-Policy-Report-Only` first lets you catch blocked third-party scripts or fonts in browser console logs before enforcing strict blocking.

Why is `unsafe-inline` discouraged in `script-src`?

Allowing `unsafe-inline` permits injected inline `<script>` tags to execute, weakening XSS protection; prefer nonces, hashes, or external bundled scripts instead.

Related Tools

  • HTTP Security Header Auditor - Paste raw HTTP response headers (from curl or DevTools) to audit HSTS, CSP, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, and Permissions-Policy.
  • X.509 PEM Certificate Expiry Inspector - Paste any PEM-encoded SSL/TLS certificate (-----BEGIN CERTIFICATE-----) to decode validity dates, remaining days, and SHA-256 fingerprint offline.
  • 301 & 302 Redirect Rule Generator - Generate clean 301/302 redirect rules for Apache .htaccess, Nginx, Netlify _redirects, and Vercel vercel.json.