Free Content Security Policy (CSP) Generator
Easily scaffold a strict Content Security Policy to protect your site against Cross-Site Scripting (XSS) and data injection. Configure your allowed sources, generate the header, and add it to your server.
Why Do You Need a Content Security Policy?
A Content Security Policy (CSP) is an added layer of HTTP security that helps detect and mitigate certain types of attacks, primarily Cross-Site Scripting (XSS) and data injection attacks.
By defining a strict CSP, you tell the browser explicitly from which domains it is allowed to load executable scripts, stylesheets, fonts, and images. If an attacker manages to inject malicious code into your HTML, the browser will refuse to execute it because it doesn't match your policy.
Related Tools and Guides
Verify your security policies in production
Generating a CSP is just the first step. Run a full SitePrivacyScore audit to see how your entire site behaves, check for missed trackers, and validate all your HTTP response headers.
For deeper runtime checks, run the full privacy audit →