CSP Starter Builder
Generate a restrictive Content-Security-Policy starting point.
Read the guideRun the tool
The calculation runs in your browser. This tool does not send your input to JVR Software.
More information
Back to the toolWhat it is and when to use it
Content Security Policy Builder creates a starter header for a web app you operate. Content Security Policy tells browsers which sources and resource types your page is allowed to load. It helps a maintainer document allowed origins and reduce the impact of unexpected script, style, image or frame loads.
How it works
A policy contains named directives, each with a list of allowed source expressions. Default sources provide a fallback for some resource types. Dedicated directives take precedence for their respective resource types. The generator produces a starting point using the groups shown on the form, so you can adapt it to your actual application.
How to use it
- Inventory the app’s first-party resources and legitimate external services.
- Build a candidate policy, read every directive and remove allowances the application does not need.
- Try it in staging or in a report-only deployment and check browser feedback before deciding how to enforce it.
Worked example
If the site serves everything from its own origin except an approved image CDN, review the image source directive to ensure that CDN is allowed. Then load representative pages, including logged-in workflows and error pages, because they may use different legitimate resources.
The optional origin field makes a connection allowance through connect-src. It does not change the image directive or automatically configure other resource types. If a browser reports that image loading was blocked, assess the image rule specifically rather than adding unrelated origins to connection handling.
Reading the result
The self keyword refers to the origin of the served document. A scheme-wide HTTPS allowance can permit every HTTPS origin for its directive. A data source can be wider than you intend. Pay particular attention to any inline allowances. Review the resulting header as a whole and test it against the paths people actually use.
Common mistakes and limits
CSP works as one layer alongside proper output encoding, maintained dependencies and authorization. A strict-looking policy can block needed resources, and a broad policy may provide less protection than expected. Report-only mode can reveal violations before the policy affects visitors.
