Build CORS response headers and catch the configuration mistakes that browsers reject or that expose your API.
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
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
Fill in the directives your site needs. The defaults are a strict starting point.
- 2
Read the warnings: they identify the specific choices that make a policy ineffective rather than merely strict.
- 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.
Related tools
Other tools you might reach for next.
Parse a raw HTTP header block, explain each header, and flag security-relevant and missing ones.
Format and indent JSON, with optional alphabetical key sorting and a precise syntax error when it will not parse.
Strip every byte of insignificant whitespace from JSON and report the saving.
Check that JSON is syntactically valid, report its structure, and flag duplicate keys that JSON.parse accepts silently.
Compare two JSON documents structurally, by path, distinguishing a type change from a value change.
Evaluate a JSONPath expression against a document and see every match with the path that produced it.
Escape text so it can be embedded as a JSON string value, handling control characters and astral code points.