Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; connect-src 'self' https://api.example.com; font-src 'self'; object-src 'none'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests;
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; connect-src 'self' https://api.example.com; font-src 'self'; object-src 'none'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests;" always;
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; connect-src 'self' https://api.example.com; font-src 'self'; object-src 'none'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests;">
Pin this tool to your browser side panel
Access this utility anytime with Alt+M without switching tabs. 100% offline & free.
How to Construct a Strict CSP Header
- 1Configure source expressions for script-src, style-src, img-src, connect-src, and framing controls.
- 2Watch real-time XSS warnings for permissive directives like unsafe-inline or wildcard *.
- 3Copy the output as an HTTP header, Nginx add_header rule, or HTML <meta> tag.
Clickjacking & XSS Defense
Combining strict script-src, object-src none, and frame-ancestors mitigates injected script execution and iframe embedding attacks.
Frequently Asked Questions
Enjoying Content Security Policy (CSP) Builder & Validator?Help your engineering peers discover private, ad-free tools!
MiniToolDesk is 100% free and client-side. Your support keeps the web ad-free.
Related Developer Utilities
UUID / GUID v4 Generator
Generate cryptographically secure random UUID v4 identifiers in bulk
Crypto Hash Calculator
Compute SHA-256, SHA-512, SHA-1, and MD5 hashes purely client-side via Web Crypto
JWT Builder & Signer
Build, mock, and sign JSON Web Tokens with HMAC-SHA256 in browser memory
HTTP Security Headers Analyzer & Hardening Fixer
Audit raw HTTP response headers against OWASP best practices with A+ to F grading and Nginx fixes.