CSP Generator
Build a browser-only Content-Security-Policy response header with editable directives, Report-Only mode, and basic pasted-policy text checks.
Build a Content Security Policy (CSP) response header by choosing source expressions for common directives. You can also inspect pasted policy text for a small set of static warnings.
This browser-only tool does not visit your site or certify a policy. Start with Report-Only on your own server, then test real application journeys before enforcing changes.
Build a policy header
Enter one or more source expressions separated by spaces. Empty directives are omitted.
The validator supports common keywords, schemes, host sources, ports, simple paths, and nonce/hash forms. It is not a full CSP grammar validator; IPv6 literals and uncommon source forms may be rejected.
Fallback for fetch directives without a more specific rule.
Scripts and script-related execution.
Stylesheets and inline style attributes.
Images and favicons.
Web fonts.
Fetch, XHR, WebSocket, and EventSource connections.
Audio and video.
Plug-in content such as object and embed.
Nested browsing contexts loaded by this page.
Workers, shared workers, and service workers.
URLs allowed in a document base element.
Destinations for submitted forms.
Parents allowed to embed this page; use an HTTP header.
Generated response header
Review pasted policy text
Paste a policy value or complete CSP response-header line. The check is static and limited to the rules listed below.
How to use this CSP generator
- Choose an editable example or enter sources for the directives your application needs.
- Review the generated header and any source validation messages.
- Use Report-Only while checking your application’s real resource needs, then configure and deploy the response header on your server.
- Paste an existing policy to see basic text warnings; verify deployment behavior with your own browser and server setup.
This builder supports common fetch and document directives shown above. It does not implement the full CSP grammar, generate production nonces, or produce server configuration.
For related configuration help, see the .htaccess Generator and the MDN CSP guide.
CSP Generator features
Compose a browser-only Content-Security-Policy response header and review pasted policy text with limited static checks.
- Compose 13 common CSP directives in a stable order with duplicate sources removed.
- Use editable same-origin and CDN example presets.
- Generate enforcing or Report-Only response-header names.
- Review pasted policy text for malformed or unsupported directives and common permissive patterns.
- Copy the policy value or full response-header line, and download the exact header without uploading policy values.
CSP Generator FAQ
What does a Content Security Policy do?
A Content Security Policy is an HTTP response header that lets a site describe which sources browsers may use for resources such as scripts, styles, and images. It is one layer of defense and must match the application that serves it.
What is the difference between CSP and Report-Only?
Content-Security-Policy enforces the listed rules. Content-Security-Policy-Report-Only reports violations without blocking them; receiving reports still requires reporting configuration on your server.
Does this generator verify my website or guarantee security?
No. It composes policy text and checks pasted text for a small set of common issues. It does not load your site, validate every CSP rule, or certify compatibility or security.
Does my policy leave this browser?
No. The composer and text review run in this page. Copy and download are browser actions; the tool does not submit policy values to a service.