Content Security Policy (CSP) Generator

Build strict CSP headers with directive toggles, nonce/hash builders, and header + meta exports.

Tool Guide

Content Security Policy (CSP) Generator: What It Does

Constructs Content Security Policy (CSP) HTTP headers with directive builders, nonces, and SHA hashes. It includes policy security scoring, flags dangerous bypasses (like 'unsafe-inline'), and exports server configs.

Example

Input
default-src 'self'; script-src 'self' 'nonce-rAnd0m'
Output
Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-rAnd0m';

Assembles directives into a standard CSP response header.

How to Use

  1. Configure directives (default-src, script-src, style-src, img-src) using checkboxes.
  2. Add trusted domains, nonces, or hash tokens for inline assets.
  3. Copy the header for Nginx, Apache, or HTML meta tag integration.

Limitations

  • Audit scores evaluate policy strictness; actual browser enforcement must be tested live.
  • HTML meta tags cannot enforce frame-ancestors, report-uri, or sandbox directives.

Frequently Asked Questions

Why is 'unsafe-inline' considered dangerous in a Content Security Policy?

'unsafe-inline' permits execution of arbitrary inline scripts, disabling the core defense CSP provides against Cross-Site Scripting (XSS).

What is the purpose of the Content-Security-Policy-Report-Only header?

Report-Only monitors and logs policy violations to an endpoint without actually blocking resources, letting you test policies safely before enforcement.

Inputs stay in browser memory. No external request is required for this operation, and zero data leaves your device.