SECURITY TOOLS

CSP Generator & Evaluator

Build a starter Content Security Policy or review a raw policy for a focused set of explainable weaknesses—without assigning a misleading security score.

LOCAL POLICY ANALYSIS

Build or evaluate a policy

No policy sent

Paste the policy value or the full Content-Security-Policy header. Duplicate directives and selected risks are reported.

Starter only—your application may need additional origins.

Generated output

Policy findings

Findings are intentionally limited; absence of a warning does not prove the policy is secure.

No findings from this limited rule set.

Your policy stays in this browser. Test in Report-Only mode before enforcing changes.

CSP generator and evaluator guide

A Content Security Policy lets a site restrict where browsers may load resources and execute code. Start with the policy your application actually serves, or use the builder for a draft that you will test and refine.

Use findings as prompts, not a verdict

The evaluator flags selected patterns such as 'unsafe-inline', 'unsafe-eval', broad wildcards, insecure HTTP sources, and missing object-src, base-uri or frame-ancestors directives. It does not model every CSP directive, browser version, application route, nonce flow, hash, or third-party dependency.

A nonce must be generated securely on the server for each response and match the nonce attribute on the allowed element. A hash must match the exact inline content. This tool does not create production nonces or hash an application's inline code. Never copy a generic policy into production without testing the site's required scripts, styles, images, connections, fonts and embeds.

Roll out with Report-Only first

Where supported, deploy Content-Security-Policy-Report-Only to observe violations without blocking the page. Review reports against actual application behavior, remove unnecessary sources, and only then consider an enforcing header. The builder's same-origin starter may break sites that depend on inline code, remote assets, analytics, APIs or embedded content.

Apache: Header set Content-Security-Policy-Report-Only "default-src 'self'; ..."
Nginx:  add_header Content-Security-Policy-Report-Only "default-src 'self'; ..." always;

These are illustrative snippets; configure your server module, quoting and policy value for your environment.

Frequently asked questions

Should I deploy the generated policy immediately?

No. Start with Content-Security-Policy-Report-Only where possible, inspect real violations, and adjust the allow-list before enforcing. A policy that is too strict can break scripts, styles, images, APIs, embeds or other site features.

Does the evaluator give a security score?

No. It reports a narrow set of explainable findings such as unsafe-inline, unsafe-eval, broad wildcards and missing defensive directives. It is not a complete security audit or proof that a policy is safe.

How should I use nonces or hashes?

A nonce must be unpredictable and freshly generated for each response, then placed both in the CSP source list and on the matching script or style element. A hash must match the exact inline content. This browser-only tool does not generate production nonces or calculate hashes for your application.

Can I put every directive in a meta element?

No. Some policy features, including frame-ancestors and reporting directives, are not supported from a CSP meta element. The converter omits those directives and reports each omission; an HTTP response header is generally the more capable delivery method.

Is my policy uploaded?

No. Parsing, evaluation and policy generation run locally in your browser.

Sources

  1. W3C — Content Security Policy Level 3
  2. MDN — Content Security Policy
  3. OWASP — CSP Cheat Sheet

Security note: this is a focused policy helper, not a full evaluator, automated deployment, or security certification.