CSP Builder & Linter
Build a Content-Security-Policy, or paste an existing one to audit it. Linting, explanation and output generation all run in your browser — your policy is never uploaded.
Start from
Google's recommended modern policy. Needs a fresh nonce on every response.
Paste an existing policy
Directives (11)
default-src
Default fallback — Fallback for every fetch directive that is not listed explicitly.
'self'
script-src
JavaScript — Where scripts can load from, and whether inline scripts / eval are allowed.
'nonce-REPLACE_WITH_RANDOM_PER_RESPONSE''strict-dynamic'https:'unsafe-inline'
style-src
Stylesheets — Where stylesheets can load from, and whether inline styles are allowed.
'self''unsafe-inline'
img-src
Images — Where images and favicons can load from.
'self'data:
font-src
Fonts — Where @font-face fonts can load from.
'self'
connect-src
Network requests — Targets for fetch(), XHR, WebSocket, EventSource and sendBeacon.
'self'
object-src
Plugins — Where <object>, <embed> and <applet> can load from. Should be 'none'.
'none'
base-uri
<base> URL — Restricts URLs usable in <base href>. Does NOT fall back to default-src.
'none'
form-action
Form targets — Restricts where forms can submit. Does NOT fall back to default-src.
'self'
frame-ancestors
Who can frame this page — Restricts which sites can embed this page (clickjacking protection). Replaces X-Frame-Options. Ignored in <meta>.
'none'
upgrade-insecure-requests
Upgrade insecure requests — Rewrites http:// subresource URLs to https:// before fetching.
Lint results
0 errors1 warnings4 notesA 93
- warn
style-src'unsafe-inline' in style-src allows any inline style. Style injection can exfiltrate data and deface pages.Prefer nonces or hashes for styles, or move styles to external files. - info
script-srcThis nonce looks like a placeholder.Generate a new unguessable nonce (>= 128 bits) for every single response; never reuse or hard-code it. - info
script-srchttps: is ignored by 'strict-dynamic' browsers and only a legacy fallback. - info
script-src'unsafe-inline' is ignored by browsers that support nonces/hashes. It only remains as a fallback for very old browsers. - infoNo reporting endpoint. You will not see violations from real users.Add report-uri / report-to, and roll out via Content-Security-Policy-Report-Only first.
Output
Content-Security-Policy: default-src 'self'; script-src 'nonce-REPLACE_WITH_RANDOM_PER_RESPONSE' 'strict-dynamic' https: 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests
This policy contains a placeholder nonce. Generate a fresh random nonce per response on the server and inject it into both the header and your script/style tags; a static header cannot do this.
What this policy allows
- default-srcAnything not covered by a more specific directive can load from this site's own origin (same scheme, host and port).
- script-srcJavaScript can come from inline scripts and script tags carrying the matching nonce attribute, scripts that are loaded by an already-trusted (nonce/hash) script; host and 'self' entries are then ignored by modern browsers, any HTTPS URL, and inline <script> blocks and inline event handlers (risky).
- style-srcStylesheets can come from this site's own origin (same scheme, host and port) and inline <style> blocks and style attributes.
- img-srcImages can load from this site's own origin (same scheme, host and port) and data: URIs.
- font-srcFonts can load from this site's own origin (same scheme, host and port).
- connect-srcfetch/XHR/WebSocket connections can go to this site's own origin (same scheme, host and port).
- object-srcPlugin content (<object>/<embed>) is blocked entirely (nothing is allowed).
- base-uri<base> tags is blocked entirely (nothing is allowed).
- form-actionForms can submit to this site's own origin (same scheme, host and port).
- frame-ancestorsEmbedding this page in any frame is blocked entirely (nothing is allowed).
- upgrade-insecure-requestshttp:// subresource URLs are automatically upgraded to https:// before they are fetched.
- Not listed → default-srcThese are not set explicitly and use default-src: script-src-elem, script-src-attr, style-src-elem, style-src-attr, media-src, frame-src, child-src, worker-src, manifest-src.