Build a Content Security Policy from presets, see what browsers will really enforce, and copy it for nginx, Apache, Express or a meta tag.
Initializing in your browser…
Create the integrity attribute and a ready-to-paste script or link element for a CDN file, or check an existing attribute against the file.
Make random passwords in one click, with the strength in bits calculated from the settings and the time each would take to guess.
Decode any SSL/TLS certificate in your browser: issuer, dates, host names and extensions in plain words, with host checks and chain verification.
Your policy uses 'unsafe-inline' for a few inline scripts, and you are moving to a nonce so it can go. You add the nonce first, planning to remove 'unsafe-inline' afterwards.
The policy you wrote
script-src 'unsafe-inline' 'self' 'nonce-8emk/+h69qBbrg9F+Fbtaw=='
What a browser will actually apply, and why
script-src 'self' 'nonce-8emk/+h69qBbrg9F+Fbtaw=='
script-src 'unsafe-inline' in script-src is IGNORED, because this
directive also carries a nonce or a hash. CSP Level 3
section 6.7.3.2 discards it whenever either is present.
Every inline script or style here must carry the nonce or
match a hash, or it will be blocked. Keeping 'unsafe-inline'
is still worth doing as a fallback for CSP Level 1 browsers,
which ignore the nonce instead.Adding the nonce tightened the policy before you removed anything. Modern browsers ignore 'unsafe-inline' as soon as a nonce or hash appears in the same directive, so every inline script without the nonce attribute stops running the moment the new policy ships. The builder shows the effective policy for exactly this reason. The same check lists what else this one-line policy leaves open: no default-src, and no base-uri, form-action, frame-ancestors or object-src.
Build a Content Security Policy from presets or directive by directive, and see what a browser will really enforce, including the rules that silently ignore parts of what you wrote. Get it as an HTTP header, nginx, Apache, Express or Netlify configuration, or a meta tag, with nonces and inline hashes built in.
What a CSP is for. A Content Security Policy tells the browser where a page may load scripts, styles, images, fonts and other resources from, and whether inline code may run. If an attacker manages to inject a script tag into your page, a good policy stops it from running. It is one of the strongest defences against cross-site scripting.
Start from a preset. The strict preset uses a nonce with 'strict-dynamic', the arrangement the specification recommends: scripts carrying the nonce run, and scripts they load are trusted in turn, so you do not have to list every CDN. The allowlist preset needs no nonce but blocks all inline scripts. The report-only preset blocks nothing and reports everything, which is the safe way to see what a real site does before enforcing a policy.
The rules that surprise people. Several decisions are made silently by the browser. A nonce or hash in a directive makes 'unsafe-inline' in that directive be ignored. 'strict-dynamic' makes host and scheme sources and 'self' be ignored. frame-ancestors, form-action, base-uri and sandbox are not covered by default-src, so leaving them out leaves them open. frame-ancestors, report-uri, report-to and sandbox do nothing in a meta tag. A keyword typed without quotes, such as self, is read as a host name and allows nothing. The builder applies each rule, shows the policy a browser will actually enforce when it differs from the one you wrote, and explains every finding.
Nonces and hashes. A fresh 128-bit nonce is generated for you; your server must create a new one for each response and add it to every inline script. To allow one fixed inline script or style without a nonce, paste it in and add its SHA-256, 384 or 512 hash to script-src or style-src.
Ready to paste. The finished policy comes as a header line and as nginx, Apache, Express and Netlify configuration, plus a meta element when you choose meta delivery. Everything runs in your browser.
Add the nonce to script-src and keep 'unsafe-inline' as a fallback for very old browsers; the builder shows that modern browsers then ignore 'unsafe-inline'.
Set frame-ancestors to 'none' or 'self' and deliver the policy as a header, since browsers ignore frame-ancestors in a meta tag.
Start with the report-only preset and a report-uri, collect reports for a while, then switch to enforce once nothing legitimate is being blocked.
A header whenever you can. A meta tag cannot use frame-ancestors, report-uri, report-to or sandbox, and cannot be report-only. Use a meta tag only on hosting where you cannot set headers.
When a directive also contains a nonce or a hash, modern browsers ignore 'unsafe-inline' in it. Older browsers that do not understand nonces still use it, so keeping both is a reasonable transition.
It lets scripts that carry your nonce or hash load further scripts, and makes the browser ignore host lists and 'self' in that directive. It suits sites that load scripts from many places at run time.
Not in production. The nonce must be random and different on every response, or an attacker can read it from one page and use it on another. Use the generated value to test, and have your server create its own.
The browser reports what the policy would block without blocking it. It sends reports to the address in report-uri or report-to, so set one, or the mode records nothing.
default-src is the fallback for most fetch directives. Without it, any type you did not list, such as images or fonts, can load from anywhere.
This runs as client-side JavaScript. Keys, tokens, payloads, and other inputs never leave your device.