Build a conservative starter Content-Security-Policy or Report-Only response header from simple source allowlists.
What this CSP generator includes
The starter policy uses default-src 'self', keeps scripts and styles same-origin unless you add sources, blocks plugins with object-src 'none', limits base-uri and form-action to the same origin, and lets you control frame-ancestors.
A CSP can break scripts, styles, images, fonts, API calls or embedded content when required sources are missing. Start with Content-Security-Policy-Report-Only, observe violations, then deploy an enforcing header after testing. Sites that use inline scripts or styles often need nonces or hashes; this starter tool intentionally does not add 'unsafe-inline' or 'unsafe-eval'.
Source syntax notes
Fields accept whitespace- or comma-separated entries, up to 100 sources and 2,000 characters per field. Invalid entries stop generation instead of being silently omitted. Supported examples include https://cdn.example.com, https:, wss://socket.example.com, *.example.com, data: and blob:. Host entries can include a leading subdomain wildcard, optional port and simple path. IPv6 literals, credentials, query strings, fragments, quoted keywords, nonces and hashes are outside this field parser’s scope. Syntax acceptance does not establish that a source is safe to trust.
Reference: MDN Content-Security-Policy header reference.
How to use the generated header
List the origins your application actually uses, generate the header and review every directive. The generator only produces text; it does not install a policy or change this website’s security settings. Changing an input clears the previous result and disables Copy Header until you generate again.
Scheme-only sources such as https: allow a broad class of resources rather than one hostname. Wildcards, data: and blob: also need deliberate review. A source allowlist is a starter policy, not proof that an application is protected from every script-injection risk.
Report-Only limitations
Report-Only does not block resources. This tool does not configure a reporting endpoint: inspect browser developer-console violations, and configure reporting separately if you need collected reports. Deliver the policy as an HTTP response header; Report-Only cannot be delivered through a meta tag. The generator omits upgrade-insecure-requests in Report-Only mode because that directive is ignored there.
Review the MDN Report-Only reference, then test representative pages and required integrations before choosing an enforcing policy. Existing CSP headers also matter; this tool does not inspect them.