Content Security Policy Generator
Add the services your site uses, then adjust the sources. Separate sources with spaces, for example 'self' https://cdn.example.com.
Your policy
Content Security Policy Generator
A Content Security Policy (CSP) tells browsers which sources a page may load scripts, styles, images and other resources from. A good CSP is one of the strongest defences against cross-site scripting (XSS). This generator walks through each directive, warns about unsafe choices like 'unsafe-inline', and outputs the header with snippets for Apache, nginx and an HTML meta tag.
How to use Content Security Policy Generator
- Start from default-src 'self' and add the domains your site loads from (analytics, fonts, CDNs, ads).
- Fill in the directives for scripts, styles, images, fonts, frames and connections.
- Tick Report only to test without blocking anything, and add a report URL if you have one.
- Copy the header or server snippet, deploy it, and watch the browser console for violations before enforcing it.
When it comes in handy
- Adding a first CSP to a website or web app.
- Fixing a "missing Content-Security-Policy" finding from a security scan.
- Tightening an existing policy.
Frequently asked questions
Why start with report-only?
Can I use a meta tag instead of a header?
How do I check the result?
Related guides
-
How to Create a Genuinely Strong Password (And What Sites Do With It)
What actually makes a password hard to crack, why length beats complexity, and how sites store passwords safely using hashing.
-
What Is a UUID? Versions, Uniqueness and When to Use One
What UUIDs are, how version 4 and version 7 differ, how unique they really are, and the trade-offs of using them as database keys.
-
Free PDF Tools That Never Upload Your Files: Merge, Compress, Protect and More
Most online PDF tools send your document to someone else's server. Here is why that matters, and how to merge, split, compress, sign and password-protect PDFs entirely inside your browser instead.