Deutsch

Directives

Quick Add

Live Preview

What is Content Security Policy (CSP)?

Content Security Policy is an HTTP security header that tells your browser which resources (JavaScript, CSS, images, fonts) are allowed to load on your website. CSP is one of the most effective defenses against Cross-Site Scripting (XSS) – one of the most common security vulnerabilities on the web.

When an attacker tries to inject malicious JavaScript into your website, a well-configured CSP blocks execution – even if the code was successfully injected.

Why CSP matters for WordPress

WordPress websites are among the most targeted. A CSP provides:

Avoid common CSP mistakes

Setting up CSP for WordPress

For WordPress, we recommend starting with our WordPress Standard template and testing the policy in Report-Only mode. This lets you see in the browser console which resources would be blocked, without actually breaking your site.

Frequently Asked Questions

Is the CSP Generator free?

Yes, the generator is completely free and requires no registration.

Is my data stored?

No. All CSP generation runs directly in your browser. We do not transmit any data to servers.

What is the difference between 'unsafe-inline' and nonces?

'unsafe-inline' allows all inline scripts – including those injected by attackers. Nonces (cryptographic one-time tokens) only allow specific, server-authorized inline scripts. Nonces are significantly more secure.

Can I set CSP in .htaccess?

Yes! Select ".htaccess" in the format dropdown to get the ready-to-use Apache header code. Add it to your .htaccess file in the WordPress root directory.

What does Report-Only mode mean?

With the Content-Security-Policy-Report-Only header, the policy is reported but not enforced. This lets you test a new CSP without breaking your website. Violations are reported in the browser console (and optionally to a report endpoint).