About this tool
A Content-Security-Policy (CSP) header is one of the strongest browser defences against cross-site scripting (XSS), data injection and clickjacking. However, small mistakes such as leaving 'unsafe-inline', 'unsafe-eval' or wildcard * in script-src silently weaken the whole policy.
This tool runs completely in your browser with two modes: Analyze CSP audits an existing policy directive by directive, and Build CSP lets you toggle directives or apply presets to generate copy-ready headers for raw HTTP, Cloudflare Pages (_headers) and Nginx.
Security tips
- Avoid 'unsafe-inline' and 'unsafe-eval' in script-src; use nonces, SHA-256 hashes or external 'self' scripts instead.
- Always include object-src 'none', base-uri 'self' (or 'none') and frame-ancestors 'none' (or 'self').
- Roll out strict changes with Content-Security-Policy-Report-Only first so you can catch unexpected breaks before enforcing.
Frequently asked questions
Why is 'unsafe-inline' flagged as High Risk in script-src?
If script-src allows 'unsafe-inline' without a nonce, hash or 'strict-dynamic', any attacker who injects an inline <script> tag or event handler can execute arbitrary JavaScript.
What does object-src 'none' protect against?
It blocks legacy browser plugins such as <object>, <embed> and <applet>, which have historically been abused to bypass script restrictions.
Why does duplicate directive order matter?
Per the CSP specification, browsers apply only the first occurrence of a duplicated directive and silently ignore any subsequent duplicates.
Related guides
Related tools
HTTP Security Headers Checker
Scan a website's HTTP response headers for HSTS, CSP, clickjacking, referrer and cookie protections, and get a grade.
Full Domain Security Audit
Audit a domain's RDAP age, SSL/TLS & CAA posture, Email authentication (SPF/DMARC/MX) and HTTP Security Headers in parallel.
SRI Hash Generator & Verifier
Compute SHA-256, SHA-384 and SHA-512 Subresource Integrity hashes, HTML tags and verify existing integrity attributes offline.