Free CSP Generator (Content Security Policy Builder)
Build a Content-Security-Policy header from scratch · pick directives and sources, and get a copy-ready header with the risky options explained.
100% client-side · nothing you enter is ever sent to a server or stored.
Preview · sign in with a free account to run it
Send it as an HTTP response header from your server or CDN · a <meta http-equiv> tag works too but can't set frame-ancestors.
Send it as an HTTP response header from your server or CDN · a <meta http-equiv> tag works too but can't set frame-ancestors.
How to use it
- Go through the directives (default-src, script-src, style-src, img-src, font-src, connect-src, frame-ancestors, object-src and base-uri) and tick the sources each may use.
- Add your own hosts, such as a CDN or API, under More sources.
- Choose Content-Security-Policy-Report-Only to test without blocking anything, and optionally add an HTTPS endpoint for violation reports.
- Copy the header, and check the policy in the CSP Evaluator before you deploy it.
Example
Input
default-src 'self' · script-src 'self' · img-src 'self' data: · connect-src 'self' https://api.example.com · frame-ancestors 'none' · object-src 'none' · Report-Only on
Result
Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self'; img-src 'self' data:; connect-src 'self' https://api.example.com; frame-ancestors 'none'; object-src 'none'
What the sources mean
- 'self'
- The same origin as the page: scheme, host and port.
- 'none'
- Blocks every source for that directive.
- https:
- Any HTTPS origin, including sites you don't control. Avoid it in script-src.
- data:
- Inline data URLs. Fine for images, risky for scripts.
- connect-src
- Where fetch and WebSocket calls may go. Add your API and your Supabase project URL here.
- Report-Only
- The browser reports violations without blocking them. Use it first, then switch to the enforcing header.
Go deeper
Page updated
Frequently asked questions
What's a good starting CSP?
default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none' · then add specific script-src and style-src sources as needed. Start in Content-Security-Policy-Report-Only mode to find breakage before enforcing.
Why avoid unsafe-inline?
Because it re-enables exactly what CSP exists to block: injected inline scripts. If you need inline code, use nonces or hashes instead · 'unsafe-inline' in script-src reduces your CSP to decoration.
What should a Supabase or Firebase app add?
Add your project URL to connect-src (for example https://abcd1234.supabase.co, plus wss:// for realtime), and your storage host to img-src if you show uploaded images.
Want the full picture?
This tool covers one narrow check. A full SimplyScan runs 60 checks across 14 categories · exposed keys, RLS, XSS, auth, and speed · in 30 seconds.
Run a full security scanRelated tools
Hash Generator
Generate MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes from any text · instantly and entirely in your browser.
SRI Hash Generator
Generate a Subresource Integrity hash for any script or stylesheet · paste the content or upload the file · so a compromised CDN can't tamper with it.
AES Encrypt / Decrypt
Encrypt text with a password using AES-256-GCM · and decrypt it back. Keys are derived with PBKDF2 and everything stays in your browser.