CSP Header Builder
Build Content-Security-Policy headers with guided directive and source selection.
default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests; report-uri /__csp_report_Fallback for every directive that is not set explicitly.
Where scripts may load from. strict-dynamic ignores most other sources.
Stylesheets and <style> blocks. Inline styles need unsafe-inline.
Images, favicons and data: URIs.
Web fonts. Google Fonts requires fonts.gstatic.com.
fetch, XHR, WebSocket, EventSource, beacons.
<object>, <embed>, <applet>. Prefer none.
<iframe> embeds (YouTube, Vimeo, …).
<audio> and <video>.
Web Workers and service workers.
Limits <base> tag — prevents base-uri injection.
Where forms may submit.
Who may frame this page. Cannot be set in a meta tag. Falls back to X-Frame-Options.
Build a Content-Security-Policy header. Nonce sources are generated at request time server-side — the policy below is a template. Note: frame-ancestors cannot be set via a <meta> tag, and a <meta> CSP must include every policy you want (it cannot extend an HTTP header policy).
Build a Content-Security-Policy header with guided directive and source selection, live policy preview, and conflict validation for unsafe-inline, nonces, and strict-dynamic. Copy the final header into your config.
- -13 directives with per-type source suggestions
- -Live policy string preview with copy
- -Nonce and strict-dynamic support
- -unsafe-inline / nonce conflict detection
- -upgrade-insecure-requests toggle
- -Report-only mode with report-uri/report-to
- >Adding a CSP to a new Next.js or static site
- >Migrating from a permissive CSP to strict-dynamic
- >Debugging blocked resources with report-only mode
- >Generating a policy snippet for CDN headers