CSP Builder

Content Security Policy (CSP) Generator & Evaluator

CSP Builder helps you write and check a Content-Security-Policy header. Start from a preset (strict nonce-based, static site, or SPA) and adjust each directive visually. Paste an existing policy to get an A–F grade with warnings for XSS bypasses, unsafe-inline, unsafe-eval, wildcard sources, and missing object-src, base-uri, or frame-ancestors. Generate script hashes and nonces, and export ready-to-use configuration for Nginx, Apache, Caddy, Express, Netlify, Vercel, and Cloudflare.

How to use

  1. Choose a preset that matches your site, or paste an existing policy to analyze it.
  2. Adjust directives such as script-src, style-src, and connect-src.
  3. Review the grade and fix the reported weaknesses.
  4. Generate hashes or nonces for inline scripts and copy the config for your server or host.

FAQ

What is a good Content Security Policy?

A strong policy uses nonces or hashes for scripts instead of 'unsafe-inline', sets object-src 'none' and base-uri 'none' or 'self', and restricts frame-ancestors. The strict nonce preset follows these recommendations.

How do I add a CSP header in Nginx?

Build the policy, choose the Nginx export, and add the generated add_header Content-Security-Policy line to your server block.

Why is 'unsafe-inline' a problem?

It allows any inline script to run, which makes most XSS attacks possible again and removes much of the protection CSP provides.

Build a Content-Security-Policy visually from presets, analyze an existing policy for XSS bypasses and missing directives, and generate script hashes and nonces. Outputs ready-to-paste config for Nginx, Apache, Caddy, Express, Netlify, Vercel, and more.

Start from a preset

Directives

A 100/100
default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests
221 characters ·
Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests

Analysis

  • info report-to No reporting configured; violations will not be collected.