Type a tool name, for example "keyword density" or "transcript".
Pick a preset, toggle the sources you trust, and copy a ready-to-paste CSP header.
1. Choose a starting preset
2. Configure directives
Fallback for any directive you don't override.
Where JavaScript can load from.
Where stylesheets can load from.
Where images can load from.
Where web fonts can load from.
fetch / XHR / WebSocket / EventSource endpoints.
Where iframes can load from.
audio and video sources.
object, embed, applet sources.
Where forms can submit to.
Restricts the <base href> value.
Who is allowed to embed your site in a frame.
Use the HTTPS collector supplied by your reporting service. A website URL alone does not collect reports.
3. Copy your policy
'self' = your own domain. 'none' = block everything for that directive. 'unsafe-inline' weakens XSS protection. Avoid if possible. A content security policy generator builds a Content-Security-Policy header for you, so you never have to write directives by hand. Pick a preset, adjust the allowed sources for 12 directives such as script-src and frame-ancestors, then copy the result as an HTTP header, an Apache rule, an Nginx line or a meta tag.
A Content Security Policy (CSP) is a browser security rule, sent in an HTTP response header, that lists the sources a page may load scripts, styles, images, fonts, frames and other resources from. When a page tries to load something from a source that is not on the list, the browser blocks it. That limits the damage of cross-site scripting (XSS), where an attacker manages to inject code into your pages.
A policy is a set of directives separated by semicolons. Each directive names a resource type followed by its allowed sources. For example, script-src 'self' https://cdn.jsdelivr.net means scripts may load only from your own origin and from that one CDN.
'self' allows your own origin (same scheme, host and port).'none' blocks everything for that directive, and it must be the only source in the field.data: and blob: allow those URL types, which are common for small inline images.https: allows any HTTPS source, which is broad, so use it sparingly.'unsafe-inline' and 'unsafe-eval' allow inline code and string-to-code execution. They weaken your protection.The directive default-src 'self' tells the browser to load any resource type you have not configured separately only from your own origin. It acts as the fallback for directives you leave out, which makes it a safe starting line for most policies.
CSP controls what your page is allowed to load and where it may connect. CORS controls which other websites may read responses from your server. They solve different problems, and one does not replace the other.
You can go from a blank page to a copy-ready policy in a few minutes. The interface has three numbered parts, and every change updates the output immediately.
https://cdn.example.com, or click the quick tokens ('self', 'none', data:, blob:, https:).upgrade-insecure-requests if you want browsers to load http links on your pages over HTTPS.Start with the preset closest to how your site really loads resources, then loosen only what breaks. The three presets differ mainly in how many outside sources they trust.
| Preset | What it allows | Best for |
|---|---|---|
| Strict (lock-down) | Same-origin only, no frames or objects | Static sites with no third parties |
| Balanced (recommended) | Self plus jsdelivr, cdnjs, gstatic | Typical sites using common CDNs |
| Site with Google Analytics | Balanced plus GA, GTM, Google Fonts | Sites with tracking and web fonts |
Say your blog uses the Balanced preset but loads fonts from Google Fonts. Balanced allows fonts and styles only from your own origin plus two CDNs, so the browser would block the font files and the stylesheet.
You open style-src and add https://fonts.googleapis.com. Then you open font-src and add https://fonts.gstatic.com. The generated policy now contains these two lines among its directives:
style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com https://fonts.googleapis.comfont-src 'self' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://fonts.gstatic.comEverything else stays locked to your own origin, so images, scripts and form submissions are still restricted. Before enforcing, tick Report-Only mode, deploy, and browse your key pages with the browser console open. If no violation messages appear, untick Report-Only and deploy the enforcing version.
The output panel shows the same policy in four formats, plus warnings and errors that tell you what to fix. Use the format that matches where you control your site.
Report-Only mode makes the browser check your policy and report violations without blocking anything, so you can find problems before visitors do. The generator labels the header accordingly, which is why testing first is the safest path to enforcement.
Several things change in this mode. The upgrade-insecure-requests option is ignored and left out, because browsers do not apply it in Report-Only. The meta tag tab is not available for Report-Only, since that mode works only as an HTTP header. Without a reporting endpoint, you will only see violations in the browser console.
If you add an endpoint, it must be an absolute HTTPS address without a username or password. A normal website URL does not collect reports on its own, so use the collector address from your reporting service. Your server also needs to send the matching Reporting-Endpoints response header. The reporting setting appears in header-style output only, not in the meta tag.
Yes, avoid 'unsafe-inline' in script-src whenever you can. It lets any inline script run, including one an attacker injects, which removes most of the XSS protection a CSP provides.
The better route is to allow specific inline code with a nonce or a hash. You can type values such as 'nonce-abc123' or 'sha256-...' straight into script-src or style-src, and the generator accepts them. It does not create nonce values for you. A nonce must be a fresh random value on every page response, so your application has to generate it and place the same value in the header and on each inline script tag.
Note that the Balanced and Google Analytics presets include 'unsafe-inline' for styles, and the Google Analytics preset also allows it for scripts. Those presets are practical starting points, not final answers. Tighten them once you have moved inline code to files or added nonces.
A good policy is as narrow as your site allows and tested before it is enforced. These habits prevent most problems.
https: in script-src allows scripts from any HTTPS site.The generator builds policy text. It does not scan your site, so it cannot tell which third-party hosts your pages call. You supply those sources, and you confirm the result in a browser.
The directive frame-ancestors works only in an HTTP header, so it is left out of the meta tag output, and you will see a warning saying so. The obsolete block-all-mixed-content option is shown disabled and is never generated; use upgrade-insecure-requests instead. The tool also produces one site-wide policy, so pages that need different rules require separate configuration on your server.
Ready to lock down your site? Choose a preset above, adjust the sources, and copy your policy in Report-Only mode. Once it is live, run your domain through the security headers checker to confirm the header is being sent. If you are also switching a site to HTTPS, you can inspect your SSL certificate with the certificate decoder, and you will find more utilities in the security and encryption tools collection.
Your report has been submitted. We will look into this issue.
A VPN changes your network exit. It does not guarantee anonymity.
Themes, plugins, code, video, audio, graphics & more from 90,000+ authors.
Web Development
Design & Media
Unlimited Access
Explore Envato Market