01What is CSP Validator?
A Content-Security-Policy that looks fine can still fail in quiet ways. Browsers skip directives they don't recognise and never tell the user. Paste a policy here and the validator splits it on semicolons into directives, lists each one with its source values, and runs a set of security checks. You can paste the bare value or the whole header line. A leading Content-Security-Policy: or Content-Security-Policy-Report-Only: is removed. Directive names are matched case-insensitively, as the spec requires, against the CSP Level 3 list. That covers the fetch directives, the -elem and -attr variants, frame-ancestors, base-uri, form-action, sandbox, report-uri, report-to, trusted-types and require-trusted-types-for. A typo like scirpt-src shows up as an unknown directive. Retired ones such as plugin-types, prefetch-src, navigate-to and block-all-mixed-content are named as removed or deprecated. A directive that appears twice is flagged, because browsers use the first one and silently drop the rest. Errors are raised for 'unsafe-eval', a bare * wildcard and data: as a script source. Keywords written without quotes are errors too, since a browser reads self (instead of 'self') as a host called self. So is 'strict-dynamic' with no nonce or hash, which blocks every script. 'unsafe-inline' is an error on its own. It drops to an informational note when a nonce, hash or 'strict-dynamic' sits next to it, since CSP2+ browsers then ignore it. Warnings cover http: sources, the broad https: scheme, 'none' mixed with other sources, nonces shorter than 128 bits, a missing default-src, and a missing object-src unless default-src is already 'none'. An empty source list is explained as equivalent to 'none'. Missing base-uri, frame-ancestors and upgrade-insecure-requests are suggestions, and report-to gets a reminder that it needs a Reporting-Endpoints header. A quick example: paste script-src self and you get an error telling you to write 'self' in quotes, plus warnings for the missing default-src and object-src. That one typo would otherwise let scripts load only from a host literally named self, which breaks your own scripts. A counter totals errors, warnings and info items, and Copy Report outputs them as plain text for a ticket or pull request. The limits are simple. It checks the policy text only. It doesn't fetch your site, so it can't tell you which real resources the policy would block.
Web security engineers, full-stack developers and DevOps staff use it to review CSP headers before shipping them. The tool runs entirely in your browser, so your data never leaves your device.
02How to use CSP Validator
- Copy the header value from your server config or browser DevTools Network tab
- Paste it into Content-Security-Policy Header Value
- Review the Parsed Directives list to confirm it split as expected
- Work through Issues Found, starting with errors
- Click Copy Report to share the findings, or Reset to clear
03Worked examples
- Input:
script-src self - Result:
error script-src: self must be written in single quotes ('self'); without them it is treated as a host name (plus warnings for missing default-src and object-src) - Input:
default-src 'none'; script-src 'strict-dynamic' - Result:
error script-src: 'strict-dynamic' without a nonce or hash blocks every script, because it makes browsers ignore 'self' and host sources - Input:
default-src 'self' data:; object-src 'none'; base-uri 'none'; frame-ancestors 'none'; upgrade-insecure-requests - Result:
error default-src: "data:" as a script source allows arbitrary script execution via data: URIs - With no script-src, scripts fall back to default-src, so data: there applies to scripts too.
- Input:
default-src 'self'; script-src 'self'; script-src 'unsafe-inline'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'; upgrade-insecure-requests - Result:
error script-src: Duplicate directive: browsers use the first script-src and ignore this one - The second script-src is not checked at all, so its 'unsafe-inline' raises no extra error.
- Input:
default-src 'none' 'self'; script-src 'nonce-abc123' 'unsafe-inline'; block-all-mixed-content; base-uri 'none'; frame-ancestors 'none'; upgrade-insecure-requests - Result:
warning default-src: 'none' only works on its own | info script-src: 'unsafe-inline' is ignored because a nonce is present | warning: Nonce "abc123" is short | warning: block-all-mixed-content is deprecated - Input:
Content-Security-Policy: default-src 'self' - Result:
warning: Missing object-src | info: Missing base-uri | info: Missing frame-ancestors | info: Consider adding upgrade-insecure-requests - A pasted header line is accepted; the Content-Security-Policy: prefix is stripped before parsing.
04Common use cases
- Reviewing a CSP before adding it to an Nginx or Apache config
- Auditing the policy set in Next.js headers() or Helmet middleware during a security review
- Explaining to a team why 'unsafe-inline' in script-src undermines XSS protection
- Catching typos in directive names that browsers would silently ignore
- Comparing a report-only policy with the enforced one before switching over
- Checking a policy copied from a blog post or Stack Overflow answer before trusting it
05Tips
- Generate a new random nonce for every response; a nonce that never changes is as weak as 'unsafe-inline'.
- Modern browsers ignore 'unsafe-inline' when a nonce or hash is present, so it's often kept as a fallback for old browsers; the tool notes it rather than calling it an error.
- Deploy new policies as Content-Security-Policy-Report-Only first and watch reports before enforcing.
- frame-ancestors only works in a response header, not in a meta tag, so set it at the server or CDN.
- Fix duplicate directives first. The second copy is ignored by browsers, and the validator doesn't check its values either.
06Related concepts
Content-Security-Policy, XSS, nonce, clickjacking, report-uri, unsafe-inline.
Frequently Asked Questions
What is CSP Validator?
CSP Validator is a free, browser-based developer tool on AIDToolStack. Validate Content-Security-Policy headers It requires no installation or sign-up and works entirely in your browser.
Is CSP Validator free to use?
Yes. No sign-up, no fees and no usage cap.
Does CSP Validator store my data?
No. It runs in your browser; nothing is uploaded.