Security · resource loading

Content security policy.

Assemble a readable CSP, inspect source expressions, and test a report-only draft before enforcement. Your policy text stays in this browser.

MDN + W3C reviewed 29 September 2026HTTP response header · not a penetration test

Advertisement

Generate a header

SourcesSpace-separated expressions; keep the list narrow.

The starter policy is intentionally conservative. This generator never invents a nonce or hash. Add those server-generated values only after you have tied them to exact response content.

Generated header

Generate a header to see the result.

The validator will flag unknown directives, malformed sources, and risky allowances.

Validate an existing policy

Paste only a policy you are authorized to inspect.

Your validation result will appear here.

What this checks

Nonce and hash guidance: a nonce must be unpredictable and freshly generated for each response; a hash must match the exact inline content. This page only recognises their shape and never fabricates a security token or proves deployment safety.

MDN CSP header reference · MDN CSP deployment guide · W3C CSP Level 3

Worked example: build a report-only header, then validate a risky one

Choose report only and set default-src 'self' and img-src 'self' data:. The generator joins the directives with semicolons and picks the matching header name.

StepInputOutput
Generate (report only)default-src 'self'; img-src 'self' data:Content-Security-Policy-Report-Only: default-src 'self'; img-src 'self' data:
Validatedefault-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.example.com; img-src *Valid, with one warning: script-src includes 'unsafe-inline'; prefer nonces or hashes for inline code

Report-only mode logs violations without blocking, which is how you test a policy before you enforce it.

Next steps: Permissions-Policy generator, security headers analyzer, Cache-Control analyzer, or HTML validator.

Frequently asked questions

What is the difference between Content-Security-Policy and Report-Only?

The enforcing header blocks violations. The Report-Only policy records violations without enforcing that policy. An enforcing policy or other browser controls can still block content.

Why is unsafe-inline flagged?

Without an effective nonce or hash policy, it permits inline scripts and weakens protection against injected scripts. Nonces or hashes allow specific inline scripts instead.

Can I paste a policy from my live site?

Yes, as long as you are allowed to inspect it. The validator reads the text only and does not fetch your site.

Is a clean result a security audit?

No. It checks the header syntax and some risky patterns, not your application.

Advertisement
Advertisement