Content Security Policy Builder

Build a CSP header and spot directives that weaken browser protections.

Your policy stays in this browser. Nothing is sent to a server.

Test a new policy with Content-Security-Policy-Report-Only before enforcing it. CSP is defence in depth and does not replace output escaping, sanitisation, or secure application code.

Start with a preset

Presets are starting points. Add the exact origins, nonces, or hashes your application needs.

Directives

Policy review

medium priority

Inline styles are allowed. This is common for some frameworks but still weakens style injection controls.

Copy your policy

Enforcing HTTP header

Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; object-src 'none'; upgrade-insecure-requests

Report-only HTTP header

Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; object-src 'none'; upgrade-insecure-requests

HTML meta tag

<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; object-src 'none'; upgrade-insecure-requests">

Meta-tag policies cannot use frame-ancestors, sandbox, report-uri, or report-to. Prefer an HTTP response header whenever possible.

Related Tools