Content-Security-Policy Builder & Analyzer
Generate or analyze Content-Security-Policy response values. Validates common directives and their source expressions, flags unsafe-inline, unsafe-eval, wildcard sources, and missing default-src, and explains report-only rollout and supported directives.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
What this CSP tool builds and checks
This tool builds or analyzes Content-Security-Policy response values. Analyze mode returns a table of each directive, its sources and a valid or review status, plus issues such as unknown or duplicate directives, a missing default-src, broad wildcard sources and the unsafe keywords. Build mode joins the filled directive fields into a policy string.
When to build or audit a policy
Reach for it when writing a policy from scratch, or auditing one a colleague or a scanner handed you. Build mode stands up a strict first policy quickly; analyze mode flags a policy that leans on unsafe-inline or opens a wildcard you meant to avoid.
The mode switch and the directive fields
Mode chooses analyze or build. In build mode the source fields for default-src, script-src, style-src, img-src, connect-src, frame-ancestors and object-src are assembled, each trimmed and skipped when blank. The tool refuses to build an empty policy or one that trips its own analyzer.
What the analyzer flags
The analyzer recognises a fixed set of known directives and reports anything else as unknown. A missing default-src is flagged because unlisted directives would have no fallback, duplicate directives are reported because later ones override earlier ones, and unsafe-inline or unsafe-eval weaken the directive they appear on.
Where the policy is parsed
The policy is parsed and rendered entirely in your browser. Nothing is sent to a server, no request is made, and the analysis keeps working offline.
Questions
What does CSP protect against?
It constrains which resources a page may load (and where scripts may run), reducing XSS and data-injection risk when configured correctly.
Is unsafe-inline always bad?
unsafe-inline weakens CSP for the relevant directive. Use nonces or hashes when you need inline scripts or styles.
What is report-only mode?
Content-Security-Policy-Report-Only reports violations without enforcing them, which is the recommended way to test a policy before roll-out.
Related tools
See category- HTTP Security Headers Analyzer
- X-Frame-Options Builder & Analyzer
- HTTP Header Analyzer
- :nth-child An+B Evaluator
HTTP Security Headers Analyzer
Review pasted HTTP response headers for common browser security protections.
X-Frame-Options Builder & Analyzer
Build or inspect clickjacking frame controls.
HTTP Header Analyzer
Paste any HTTP headers and auto-detect, parse and check every one of them.
:nth-child An+B Evaluator
Parse CSS An+B (:nth-child, :nth-of-type) microsyntax, validate it, and list which child indices it matches.