Skip to content

Security

Content Security Policy Builder

Build and review Content-Security-Policy headers with visual directives and security warnings.

Loading tool…

Find this tool in

Helpful references

About this tool

What is Content Security Policy Builder?

Draft a Content-Security-Policy from the resources a page actually needs. A policy constrains permitted sources and behaviors; it does not sanitize content or repair an application's vulnerabilities. Start with an inventory of scripts, styles, frames and network connections, and review the generated directives in the real deployment before enforcing them.

A worked example

Understand a restrictive starting fragment

Example input

default-src: 'self'
object-src: 'none'

Expected result

default-src 'self'; object-src 'none'

The fragment limits default sources to the same origin and disallows object resources. It is not a complete policy for every application. Inline scripts, external fonts and API calls may need deliberate additional rules. Use the reporting workflow supported by your application to identify legitimate resource failures before moving to enforcement.

Common mistakes and limits

  • Broad wildcards or unsafe exceptions can undermine a policy's intended protection. Review warnings in the context of the application's actual resource requirements.
  • A policy copied into documentation is not active on a server. Inspect the published response headers and browser reports after integration.

Features

What you can do

  • Enable and disable common CSP directives.
  • Configure sources for scripts, styles, images, connections and frames.
  • Add custom origins, schemes, nonces and hashes.
  • Detect invalid combinations involving 'none'.
  • Warn about 'unsafe-inline', 'unsafe-eval' and wildcard sources.
  • Validate basic nonce and hash syntax.
  • Generate a complete Content-Security-Policy header.
  • Generate an HTML meta tag.
  • Enable upgrade-insecure-requests and block-all-mixed-content.
  • Load common CSP templates.
  • Copy generated policy values.
  • Build and analyze policies locally in your browser.

Frequently asked questions

Questions about Content Security Policy Builder

What is Content Security Policy?

Content Security Policy is a browser security mechanism that restricts which resources a page may load or execute.

Why is 'unsafe-inline' discouraged?

It allows inline scripts or styles and weakens CSP protections. Nonces or hashes are usually safer alternatives.

What does frame-ancestors control?

It determines which sites may embed the current page in a frame or iframe.

Can I use a meta tag instead of an HTTP header?

Some CSP directives can be delivered through a meta tag, but an HTTP header is generally preferred and supports the complete policy more reliably.

Should I test a policy before enforcing it?

Yes. Use Content-Security-Policy-Report-Only first to detect blocked resources before enforcing a production policy.

Does this tool test the policy against my website?

No. It builds and analyzes the policy locally but does not crawl or execute your website.

Related tools