Skip to content
Zesona
Content Security Policy BuilderLocal

Content Security Policy Builder

Build a Content-Security-Policy header and audit it for the weaknesses that silently make a policy useless.

  • Free
  • No sign-up
  • Runs in your browser

Input

Runs in your browser

Reports violations without blocking. Deploy this way first.

Ready

Everything happens on this device. No upload, no account, no network request.

How to use this tool

  1. 1

    Fill in the directives your site needs. The defaults are a strict starting point.

  2. 2

    Read the warnings: they identify the specific choices that make a policy ineffective rather than merely strict.

  3. 3

    Deploy in Report-Only mode first to find what would break, then enforce.

Questions about Content Security Policy Builder

Why does unsafe-inline make my policy pointless?

Because blocking inline script is most of what CSP does. With `'unsafe-inline'` in script-src, an injected `<script>` tag or `onerror=` attribute executes exactly as it would with no policy at all. Use a nonce or a hash instead - and note that a browser which understands your nonce ignores `'unsafe-inline'`, so you can keep both for older browsers.

Why does base-uri matter?

Because an injected `<base href="https://evil.example/">` tag rewrites every relative URL on the page, including your script `src` attributes. `default-src` does not cover it, so `base-uri 'self'` has to be set explicitly. It is the most commonly missed directive.

Do I still need X-Frame-Options?

Only for very old browsers. `frame-ancestors` supersedes it and is more expressive. Setting both is harmless; where they conflict, CSP wins in browsers that support it.

Why is my CSP breaking in production but not locally?

Usually because `connect-src` does not list your API origin, so every fetch is blocked - and the error appears in the console rather than as a failed request, which makes it easy to miss. Report-Only mode would have shown this before it mattered.

Is my data sent anywhere?

No. This tool runs as JavaScript inside your browser tab. There is no network request carrying your input, nothing is written to a server log, and it keeps working with your connection switched off. You can confirm it in the browser’s network panel. That matters more here than elsewhere on the site: developer tools handle tokens, keys and production data.

Other tools you might reach for next.