Skip to main content

CSP Policy Builder

Build your Content-Security-Policy header directive by directive. Each setting shows an explanation of what it does and the security trade-off.

✓ All major CSP directives ✓ Report-Only mode ✓ Express, Nginx & meta tag output

Preset

Directives

Security Score

—

Header

 
 

Frequently Asked Questions

What is Content-Security-Policy?▼

CSP is an HTTP response header that tells browsers which sources are allowed to load scripts, styles, images, fonts, and other resources. A well-configured CSP is one of the most effective defenses against XSS attacks — even if an attacker injects a script tag, the browser won't execute it unless the source is allowlisted.

What is default-src?▼

default-src is the fallback for all resource fetch directives (script-src, style-src, img-src, etc.). Any directive you don't explicitly set falls back to default-src. Always set a restrictive default-src ('self' or 'none') and only loosen specific directives you need.

Why is 'unsafe-inline' dangerous?▼

'unsafe-inline' allows inline <script> and <style> blocks. This defeats XSS protection because injected inline scripts execute freely. Use nonces (a random per-request value in script-src 'nonce-{value}') or hashes (sha256-{hash}) instead. For styles, move inline styles to external .css files.

What is report-uri / report-to?▼

report-uri (legacy) and report-to (modern) tell the browser where to POST violation reports when a resource is blocked by CSP. Use Content-Security-Policy-Report-Only header with report-to while auditing — no resources are blocked, only violations reported. Then switch to Content-Security-Policy when confident.

How do I test CSP without breaking my site?▼

Use the Content-Security-Policy-Report-Only header first. Set report-to to a service like report-uri.com or your own endpoint. Monitor violations for 1-2 weeks. Iterate until violations stop, then switch to enforcing CSP. The Report-Only header never blocks anything — safe to test in production.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Webhook Tester WebSocket Tester WebP Converter WebSocket Test Client HTTP Status Code Reference HTTP Status Code Reference HTTP Status Code Lookup HTTP Status Code Lookup Core Web Vitals Guide HTTP Headers Analyzer HTTP Methods Reference HTTP Security Headers Generator Web Vitals Scorer HTTP Header Analyzer Web Vitals Analyzer HTTP Security Headers Checker Core Web Vitals Budget Calculator API Request Builder HTTP Headers Inspector HTTP Status Code Reference PWA Manifest Generator Haproxy Config Validator Caddy Caddyfile Generator HTTP Cache-Control Builder WASM Module Explorer HTTP/2 Server Push Headers Builder Lighthouse Score Simulator Core Web Vitals Calculator Content Security Policy Builder HTTP Header Inspector WebAssembly Binary Inspector Web Vitals Budget Planner HTTP Cache Header Builder Prompt Injection Tester GCP Service Account Key Auditor Web Performance Checklist Image Optimizer Checklist AI System Guardian API Response Formatter & Analyzer API Response Mock Generator HTTP API Tester Color Blindness Simulator curl Command Builder .htaccess Generator HTTP Code Snippet Generator Interview Question Generator JWT Builder JWT Decoder nginx Config Generator Password Strength Checker Developer Utilities Service Worker Generator HTTP Mock Response Builder HMAC Generator CSP Header Builder AWS IAM Policy Validator WCAG Contrast Checker HTTP Cookie Parser HAR Diff Analyzer SBOM Generator JWT Debugger Pro Dockerfile Linter Bundle Size Estimator SSL Certificate Checker REST API Request Builder nginx Config Builder Cypress Frontend Testing Guide Mock Service Worker (MSW) API Mocking Guide API Response Mocker Docker Layer Optimizer Bundle Size Impact Calculator TTFB Analyzer Password Strength Analyzer JWT Decoder & Validator CSS Flexbox Visualizer

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →