CSP Generator
Build a Content Security Policy with the free CSP Generator. Configure directives that control which sources your website can load scripts, styles, images, fonts and other resources from. Generate a starter CSP header for your web application, then adapt it to your actual dependencies and test it carefully. An overly restrictive policy may break site functionality, while a permissive one may provide limited protection.
A basic Content Security Policy for a same-origin site. Load the example to see the tool in action.
What is CSP Generator?
Create a Content Security Policy (CSP) header with the free CSP Generator. Configure directives for the sources your website can use to load scripts, stylesheets, images, fonts and other resources. Generate a starter policy for your website or web application and adapt it to your actual dependencies. Test the policy carefully to identify blocked resources and avoid weakening protection with unnecessarily broad permissions.
Why use this tool?
- Generate common web files and snippets from a few inputs.
- Avoid syntax mistakes in boilerplate.
- Get a starting point you can adapt to your project.
How to use CSP Generator
- Step 1. Fill in the options the tool asks for.
- Step 2. Review the generated output.
- Step 3. Copy it into your project and adjust it for your site.
Common use cases
Start with a restrictive Content Security Policy
Treat this as a starting point only: test your site's required scripts, styles, images, and connections before enforcing a policy.
Content-Security-Policy: default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'Important notes
- Review generated output before using it in production.
More Web Generators Tools
CSP Generator FAQ
What is CSP Generator?
Create a starter Content Security Policy header with directives for scripts, styles, images and other resources to help configure website security.
Do I need an account to use CSP Generator?
No. You can use it without creating an account.