Content Security Policy Generator
For web developers and security engineers hardening a site against cross-site scripting. You get a ready-to-paste Content-Security-Policy header assembled from the directives and sources you tick.
Close the gaps with real-world projects
Build industry projects on ByteLabs and add verified proof of your skills to your public profile.
How to use the CSP Builder
- Tick sources such as self, none, https: or data: under each directive (default-src, script-src, style-src, img-src, connect-src, font-src, frame-src, object-src).
- Avoid ticking unsafe-inline and unsafe-eval unless you truly need them.
- Click Build, or just watch the header update as you tick.
- Copy the header and test it on a staging site before enforcing it.
An example, step by step (example only)
You enter
default-src self, script-src self, object-src none
The tool shows
Content-Security-Policy: default-src 'self'; script-src 'self'; object-src 'none'
Questions about the CSP Builder
Why is 'unsafe-inline' in script-src a problem?
It allows any inline script to run, which is exactly what most cross-site scripting attacks inject. Move scripts into files or use nonces or hashes instead.
What does default-src do in a CSP?
It is the fallback for every fetch directive you do not set explicitly. Starting with default-src self and then opening only what each resource type needs is a common safe baseline.
How do I test a CSP without breaking my site?
Send the policy first as Content-Security-Policy-Report-Only, watch the browser console or reports for blocked resources, adjust, then switch to the enforcing header.
Is the CSP Builder free and private?
Yes. It is free, needs no sign-up and runs entirely in your browser, so what you type is not uploaded. You only sign in if you want to email a result to yourself or save it to your CareerByteCode profile.