CSP Builder & Validator
Build a Content-Security-Policy visually, or audit an existing header
Examples
Audit an unsafe policy
default-src 'self'; script-src 'self' 'unsafe-inline'; img-src *Score 55 — 'unsafe-inline' in script-src and the * wildcard in img-src flagged high; missing frame-ancestors flagged medium.On the Validate tab, paste a header to see exactly which directives weaken it and how to fix each one.
Confirm a strict deny-by-default policy
default-src 'none'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'Score 100 — every directive explicit, no unsafe sources.A deny-by-default policy scores 100 in the validator because no unsafe directives or wildcards are present.
About this tool
A Content-Security-Policy (CSP) header turns expected XSS, framing and injection attacks into browser-side blocks. It is a single header value made of one or more directives — default-src, script-src, style-src, img-src, frame-ancestors, and so on — each with a list of allowed source expressions. A wrong choice (for example allowing 'unsafe-inline' on script-src) reopens the very doors CSP is designed to close, so a builder that lets you see each directive's effect side-by-side is faster than hand-tuning a one-line header.
The builder follows the W3C CSP3 directive list and exposes 15 of the most-used directives with their default source sets. Each directive has a one-line description, click-to-add common sources ('self', 'none', https: scheme, 'strict-dynamic', etc.) and a button-grid of popular hostnames (CDNs, Google Fonts, Stripe, GA, GTM) so you do not have to memorize which origins your stack needs. Sources are quoted exactly the way the header parser expects — keywords with single quotes (e.g. 'self'), schemes plain (e.g. https:).
The generated header is rendered in four formats — Standard HTTP, Nginx add_header, Apache Header always set, and a Next.js middleware snippet — plus a Report-Only mode that switches the header name and adds an optional report-uri for collecting violations without enforcing them. A live Security Score surfaces the cost of every choice: 'unsafe-inline' (-10), 'unsafe-eval' (-15), http: scheme (-20 per directive), broad https: scheme (-5 per directive). The header leaves your browser only when you copy it; nothing is uploaded.
How to use
Start with default-src 'self'
Open default-src and confirm it has 'self'. This single directive is the fallback for every fetch type — without it you must declare every other source individually.
Add the directives your stack needs
Click script-src, style-src, img-src, font-src, connect-src, frame-src, frame-ancestors, etc. Click common-source chips or popular-domain buttons to add sources without typing URLs.
Watch the Security Score as you add sources
Each 'unsafe-inline' lowers the score by 10; each 'unsafe-eval' by 15; http: by 20; https: by 5. Aim to keep the score above 80 unless a hard requirement forces a relax.
Switch to Report-Only first
Toggle Report-Only, set the report-uri endpoint, and ship the header in monitoring mode. Once violations stop, switch to enforce mode for production.
Copy the format your server uses
Use the Standard tab for documentation, Nginx for sites-available, Apache for .htaccess, or Next.js to drop a middleware file directly into your app.
Use cases
Validate before you ship
Paste a candidate CSP into the Validate tab to catch unsafe-inline or wildcards before the header reaches production.
Score an existing site
Copy the live Content-Security-Policy header and get a 0–100 risk score plus ranked fixes.
Common mistakes
Mistake:Trusting a policy because it has many directives.
Fix:default-src is the backbone — without it, every unspecified resource type is allowed. Always set default-src.
Mistake:Keeping 'unsafe-inline' to avoid breakage.
Fix:Move to nonces or hashes, or 'strict-dynamic', so inline scripts are gated instead of globally allowed.
Frequently asked questions
Related guides
Content-Security-Policy: Build It Right, Then Audit It
A practical guide to authoring a strong Content-Security-Policy and auditing one you already ship. How default-src, unsafe-inline, wildcards and frame-ancestors affect your real XSS protection.
HTTP Security Headers Explained: HSTS, CSP, and the Rest
A practical guide to response security headers. What HSTS, Content-Security-Policy, X-Frame-Options, X-Content-Type-Options, Referrer-Policy and Permissions-Policy actually do, and the weak values to avoid.
References & standards
Related tools
AES Encryption
Encrypt and decrypt text with AES-GCM and a passphrase, fully in your browser. Uses PBKDF2 key derivation and the Web Crypto API — your data and keys never leave your device.
Basic Auth Generator
Generate an HTTP Basic Authentication header from a username and password. Produces the Authorization header and ready-to-use curl and fetch snippets. Runs fully client-side.
Bcrypt Generator & Verifier
Hash passwords with bcrypt and verify hashes — choose your cost factor (rounds 4–15), get a secure hash instantly, and check whether a password matches a hash. Runs entirely in your browser.
BIP39 Mnemonic Generator
Generate and validate BIP39 seed phrases locally for testing
Checksum Calculator
Compute file checksums (SHA-1, SHA-256, SHA-384, SHA-512) in your browser with the Web Crypto API
CORS Header Validator
Validate Cross-Origin Resource Sharing headers for security compliance