Tools

Content Security Policy Generator for WordPress – Free & No Sign-Up

by Sven Kilcher·

With the free CSP Generator from WP Helping Hand, you can build your Content-Security-Policy header directly in your browser - no registration, no data leaving your device. Protect your WordPress website from XSS attacks.

Content Security Policy Generator for WordPress – Free & No Sign-Up

Imagine someone injects a script into your website that reads everything your visitors type into forms - passwords, contact details, payment information. Your WordPress installation runs flawlessly, the plugin audit was clean, and it still happens. These attacks are called Cross-Site Scripting, or XSS. They’ve been one of the most common attack vectors on the web for years - and a correctly configured Content-Security-Policy header would render most of them harmless.

With the free CSP Generator from WP Helping Hand, you can now do this directly in your browser - no registration, no data leaving your device, a ready-to-copy header line.

What is a Content-Security-Policy header?

When a browser loads your website, it requests every piece of content: JavaScript, CSS, images, fonts, embedded videos. By default, it’s allowed to load these from anywhere. The Content-Security-Policy header, or CSP, changes that. It tells the browser explicitly: scripts may only be loaded from my own server. Everything else: blocked.

The most important CSP directives for WordPress websites:

  • default-src: fallback for all content types without their own directive - baseline: 'self'
  • script-src: controls where JavaScript can be loaded from
  • style-src: for CSS - Google Fonts needs https://fonts.googleapis.com
  • font-src: for fonts - for Google Fonts: https://fonts.gstatic.com
  • img-src: for images, including external CDNs; data: allows base64 images
  • frame-src: for iframes - YouTube needs https://www.youtube.com
  • connect-src: for AJAX requests, WebSockets, and API calls
  • form-action: defines where forms are allowed to send data

Why is CSP especially relevant for WordPress?

WordPress websites are a popular attack target - not because WordPress itself is insecure, but because so many plugins and themes are in circulation, and not all of them are maintained equally well. WordPress websites typically load resources from many sources: Google Analytics, Google Fonts, YouTube embeds, CDN links for jQuery, payment providers like Stripe or PayPal. Every one of these external sources is a potential entry point.

The most common mistakes with CSP headers

Directives that are too broad: script-src * allows scripts from anywhere, rendering the header useless.

Missing directives: there are more than a dozen CSP directives. If you only set script-src and forget the rest, you leave gaps.

unsafe-inline and unsafe-eval: these values allow inline scripts and dynamic code execution - exactly what attackers want to exploit.

Incorrect syntax: a forgotten semicolon or a typo, and the browser ignores the entire header.

How the CSP Generator from WP Helping Hand works

The tool runs entirely in your browser. No data is sent to a server.

Step 1: open the tool at wp-helping-hand.com/en/tools/csp-generator/ - no sign-up needed.

Step 2: configure directives - 'self' for your own content, specific domains for external sources.

Step 3: generate the header. Example result:

Content-Security-Policy: default-src 'self'; script-src 'self' https://www.googletagmanager.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https:; frame-src 'none'

Step 4: add the header to WordPress via .htaccess, functions.php, or a security plugin.

Step 5: test - open F12 → Console. Every CSP violation shows up immediately.

Tip: start with the header in Report-Only mode (Content-Security-Policy-Report-Only). That way, the header doesn’t block anything yet, but you see exactly what would be blocked in the console.

Testing CSP headers with external tools

  • SecurityHeaders.com - analyzes all HTTP security headers and grades them
  • Google Chrome DevTools - F12 → Console shows every CSP violation directly
  • CSP Evaluator (from Google) - checks a CSP policy for known weaknesses

How I roll out CSP headers for my maintenance clients

Step 1 - Capture every external source: open the browser console under “Network,” load every relevant page, and note every domain. WordPress websites often end up with 10-20 different domains.

Step 2 - Configure the CSP Generator: add every domain to the matching directive. Avoid 'unsafe-inline' or 'unsafe-eval' as much as possible.

Step 3 - Enable Report-Only mode: set Content-Security-Policy-Report-Only and click through every page.

Step 4 - Switch to the real CSP header: only once no more CSP violations appear.

Step 5 - Final test with SecurityHeaders.com: aim for at least an A, ideally an A+.

What a CSP header doesn’t replace

A CSP header isn’t a cure-all. It protects against one specific class of attack - mainly XSS. It doesn’t replace:

  • Regular plugin and theme updates
  • Strong passwords and two-factor authentication
  • Regular backups
  • A web application firewall

Conclusion

Writing a Content-Security-Policy header by hand used to be the part most people skipped. The CSP Generator from WP Helping Hand makes it faster. You configure it, you get a ready-to-use line, you add it in. No login, no data leaving your device, no subscription.

FAQ

Das willst du wissen

What is a Content-Security-Policy header?
A CSP header is an HTTP response directive that tells the browser which sources it's allowed to load content from. Scripts, styles, images, and other resources from sources not on the list get blocked automatically - protecting against XSS attacks and content injection.
Is the CSP Generator free?
Yes, completely. No registration, no subscription, no hidden costs.
Is my data stored?
No. The tool runs entirely in your browser. Your configuration is never sent to a server.
My website breaks after adding the header - what do I do?
Open the browser console (F12 → Console). It shows which resources got blocked and which domain they came from. Add that domain to the matching directive, generate a new header, and update your configuration.
Does CSP work with the WordPress admin area too?
Yes, but with caution. The WordPress admin uses inline scripts, which a strict CSP header can block. Many security plugins let you set the header only for the frontend and exclude the admin area. That's the most pragmatic approach in most cases.
Do I need a separate header for every browser?
No. All modern browsers support CSP. The syntax is standardized.
What's the difference between Content-Security-Policy and Content-Security-Policy-Report-Only?
The regular Content-Security-Policy header enforces the rules immediately - content from disallowed sources gets blocked. Content-Security-Policy-Report-Only only observes: violations get reported (e.g. in the browser console or to a report URI), but nothing gets actively blocked. That's ideal for testing. You can let the Report-Only header run for a few days, review the reported violations, adjust the header accordingly - and only then switch to the real CSP header. That way you avoid accidentally breaking something on your website.
Do I need to allow unsafe-inline for WordPress to work?
That depends on your installation. WordPress core itself and many plugins use inline scripts and inline styles - without unsafe-inline, that can lead to display errors or broken elements. On the other hand, unsafe-inline significantly weakens XSS protection, because it allows exactly what attackers want to inject. A good middle ground: allow unsafe-inline at first, test the website, then gradually check which inline scripts can be replaced with hashes or nonces. For most WordPress websites, unsafe-inline in style-src is unproblematic - but in script-src, you should look more closely.
How do I test whether my CSP header is set correctly?
The fastest way is via SecurityHeaders.com - just enter your domain and you'll immediately see which security headers are set and how they're rated. Alternatively, use your browser directly: open F12, switch to the "Network" tab, reload the page, click a request, and look for content-security-policy under "Response Headers". If the header shows up there, it's active.
Does a CSP header affect my website's load speed?
No, not noticeably. The header gets delivered once with the server's HTTP response and is only a few bytes in size. The actual evaluation happens in the browser and is fast enough to have no measurable performance impact. One thing that can help indirectly: if the CSP header reveals that your website loads third-party scripts you weren't consciously aware of, you can remove them - which actually saves load time.
Can I add the generated CSP header directly to .htaccess without a plugin?
Yes. If your hosting uses Apache (true for most WordPress shared hosting), an entry in the .htaccess file in your WordPress installation's root directory is enough: apache Header always set Content-Security-Policy "your-generated-header-here" Replace your-generated-header-here with the generator's output. Important: back up your .htaccess first. A syntax error there can cause the website to throw a 500 error. On Nginx, the header is set in the server block via add_header - that requires access to the Nginx configuration, which often isn't possible on shared hosting. In that case, a security plugin is the simpler solution.
How often do I need to update my CSP header?
Whenever the external resources on your website change. Specifically: if you install a new plugin that loads scripts from an external domain, that domain needs to be in the script-src directive - otherwise the script gets blocked. The same goes for adding a new service (e.g. a new analytics tool, a chat widget, or a payment provider). A good time to review is therefore always after major changes to the website. Practical tip: keep Report-Only mode in mind - test with it briefly after changes, before the new header goes live.
Sven Kilcher – WordPress Freelancer
WordPress Freelancer

Die WP Helping Hand, WordPress Freelancer

Sven Kilcher

Ich bin Sven, dein erfahrener Partner für alles rund um WordPress. Mit über 8 Jahren Expertise und mehr als 120 zufriedenen Kunden stehe ich dir zur Seite, um deine Website professionell zu gestalten, zu warten und weiterzuentwickeln. Ob es um maßgeschneiderte Lösungen oder regelmäßige Wartungen geht – ich bin für dich da.

44
Alter
8 Jahre
Erfahrung
120+
Kunden
50+
Wartungen