Presets
The Google Analytics + AdSense preset lists typical domains (googletagmanager.com, google-analytics.com, googlesyndication.com, doubleclick.net) — treat these as a starting point, not a guaranteed-exhaustive list for every AdSense account or GA property.
default-src
The fallback for any fetch directive that isn't explicitly set — the safety net.
If misconfigured: Leave it too loose (e.g. '*') and every other tightened directive is undermined by anything that falls through to it.
script-src
Controls which JavaScript is allowed to execute — inline scripts, eval, and external script sources.
If misconfigured: Too strict and your analytics, ad, or third-party widget scripts silently stop running with a console error; too loose and it's the #1 line of defense against XSS you've given up.
style-src
Controls which CSS is allowed to load and apply — inline style attributes, <style> tags, and external stylesheets.
If misconfigured: Many CSS-in-JS libraries and inline style= attributes need 'unsafe-inline' here or they'll render unstyled.
img-src
Controls which sources images can load from.
If misconfigured: Block a CDN your images live on and they simply won't render — broken image icons everywhere.
font-src
Controls where @font-face font files can load from.
If misconfigured: Miss your web-font CDN (e.g. Google Fonts) and the page falls back to system fonts.
connect-src
Controls which endpoints fetch(), XHR, WebSocket, and EventSource can connect to.
If misconfigured: This is the one people forget — an API call to a domain not listed here fails silently in the console, not on the page.
media-src
Controls sources for <audio> and <video> elements.
If misconfigured: A video hosted on a third-party CDN not listed here refuses to play.
object-src
Controls <object>, <embed>, and <applet> — legacy plugin content.
If misconfigured: Almost nothing legitimate needs this anymore; setting it to 'none' closes off an old Flash/Java-era attack surface with essentially zero downside.
frame-src
Controls which sources can be loaded inside an <iframe> on your page.
If misconfigured: Embed a YouTube video or a payment widget's iframe without listing its domain and the embed shows a blank frame.
frame-ancestors
Controls which sites are allowed to embed YOUR page in an iframe — the modern anti-clickjacking directive.
If misconfigured: Set to 'none' and a legitimate partner trying to embed your widget gets a blank frame too; this directive doesn't work in a <meta> tag, only the HTTP header.
base-uri
Restricts what URLs can be used in a <base> tag, which changes how all relative URLs on the page resolve.
If misconfigured: Rarely breaks anything legitimate; leaving it open lets an XSS payload inject a <base> tag that hijacks every relative link and script src on the page.
form-action
Restricts which URLs a <form> can submit to.
If misconfigured: A payment form that posts to a third-party processor's domain needs that domain listed here or the submission is blocked.
Tells the browser to rewrite any http:// URL on the page to https:// before requesting it. If your site (or an embedded resource) genuinely only has an HTTP endpoint, that resource will fail to load.
When set, browsers POST a JSON report to this endpoint every time the policy blocks something — useful for finding what you'd break before switching from Report-Only to enforced.
HTTP Header (Enforced)
Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; frame-ancestors 'self'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests
HTTP Header (Report-Only)
Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; frame-ancestors 'self'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests
<meta> Tag Equivalent
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; frame-ancestors 'self'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests">
frame-ancestors, report-uri/report-to, and sandbox have no effect inside a <meta> tag — browsers ignore them there. Use the real HTTP header if your policy needs any of those three.
Scope: This Tool Is CSP Only
This generator builds Content-Security-Policy values only. For HSTS, X-Frame-Options, Referrer-Policy, Permissions-Policy, and the other non-CSP security headers, use the companion Security Headers Generator.
100% Private
The policy is built entirely in your browser. Any nonce shown is generated locally via WebCrypto for preview — nothing you configure here is sent anywhere.