CSP Header Generator
Generate Content Security Policy headers.Runs in this tab.⌘ ↵ runs it
'self''none''unsafe-inline''unsafe-eval'data:blob:https:*
Content-Security-Policy: default-src 'self'
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">
Next step
AtriumKitFrom the team behind browserutils
Turn a click-through into an interactive demo
AtriumKit records your web app once in Chrome and turns every click into a step of a demo you can embed or share. There’s a free plan.
Try AtriumKit freeAbout CSP Header Generator
Free online CSP header generator. Build Content-Security-Policy headers with a visual editor for web security. It runs in your browser. Nothing is sent to a server.
Questions
What is a Content Security Policy (CSP) header?
A CSP header is an HTTP response header that tells browsers which sources of content (scripts, styles, images, etc.) are allowed to load on your page. It is one of the most effective defenses against cross-site scripting (XSS) and data injection attacks.
How do I test a CSP header without breaking my site?
Use the Content-Security-Policy-Report-Only header first, which logs violations to a reporting endpoint without actually blocking anything. Once you have reviewed the reports and fixed any issues, switch to the enforcing Content-Security-Policy header.
What does the unsafe-inline directive mean in CSP?
The unsafe-inline directive allows inline scripts and styles to execute. This weakens CSP protection significantly because XSS attacks typically inject inline code. Use nonce-based or hash-based allowlisting instead whenever possible.
How do I add the generated CSP header to my server?
Copy the generated header string and add it to your server configuration. In Nginx use add_header, in Apache use Header set, and in Express.js use res.setHeader(). You can also set it via a meta tag in HTML, though the HTTP header approach is preferred.
Does the CSP header generator work offline?
Yes. The generator builds CSP header strings using client-side logic with no server calls, so it works without an internet connection once the page is loaded.
Comments
More in Security & Privacy
- robots.txt Generator
- Chmod Calculator
- .htpasswd Generator
- SSH Key Generator
- SRI Hash Generator
- PGP Key Generator
- Password Strength Checker
- CORS Tester
Comments