Category: Developer tools
Content-Security-Policy Generator
Build a Content-Security-Policy header from directives
Set source lists for default-src, script-src, style-src and more, then copy the finished Content-Security-Policy header value. Built locally in your browser.
| Directive | Sources |
|---|---|
default-src | 'self' |
script-src | 'self' |
style-src | 'self' 'unsafe-inline' |
img-src | 'self' data: |
font-src | 'self' |
connect-src | 'self' |
frame-ancestors | 'none' |
object-src | 'none' |
base-uri | 'self' |
form-action | 'self' |
upgrade-insecure-requests | — |
default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; frame-ancestors 'none'; object-src 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests;
Everything on this page is processed in your browser. Nothing is uploaded.
What this tool does
A Content-Security-Policy header tells the browser which sources of scripts, styles, images and other resources a page is allowed to load, which is one of the strongest defenses against cross-site scripting. Each directive takes a space-separated source list such as 'self', 'unsafe-inline', https: or a specific domain, and getting the syntax right by hand is fiddly. This tool builds the header from one field per directive and shows the same policy as a table so you can review what you are actually allowing before shipping it.
How to use it
- Set the source list for each directive you want to restrict, such as default-src, script-src and style-src.
- Toggle upgrade-insecure-requests or block-all-mixed-content if you need them, then read the directive table to check what the policy actually allows.
- Copy the header value and send it as the Content-Security-Policy response header, or start with Content-Security-Policy-Report-Only while testing.
Privacy
This tool runs entirely in your browser. Your input is never uploaded, stored or shared — closing the tab removes it.
Frequently asked questions
- What does an empty directive mean?
- A directive you leave empty is not written into the header. Fetch directives that support fallback then follow default-src, and if default-src is empty too, that resource type is not restricted by this policy at all. Decide whether you want an explicit rule or the default-src fallback.
- Should I test with Report-Only first?
- It is the safer order. Send the same value as Content-Security-Policy-Report-Only: the browser reports violations without blocking anything, so you can see which sources would break. Switch the header name to Content-Security-Policy once the reports look clean.
- Is the policy sent anywhere to be built?
- No. The source lists you type, the directive table and the finished header value are produced locally in your browser; no domains or policy text are posted to a server. It works with the network disconnected.
- Is my input, file, or result uploaded?
- No. Inputs, files, settings and results stay in the browser and are not uploaded to LocalTools. There are no accounts, no sync and no cloud history.
- What does this tool not support?
- It assembles the header text from what you enter. It does not crawl or scan your site to discover which sources your pages actually need, and it cannot deploy the header for you. There is no batch mode, no account, no cloud history and no server-side processing.