Start a project

Tool 25 of 29 · Security

Security Headers Generator

Build a Content-Security-Policy from the services your site uses, add the other headers every site should send, and copy them for Cloudflare, Netlify, Apache or Nginx.

Security Headers Generator

Content-Security-Policy

Services your site uses
Edit each directive

Other headers

Permissions-Policy: switch off

Checks

    Turn on a new policy in report-only mode first, use the site for a day, and fix anything the browser console reports before switching it on for real.

    Your headers

    Cloudflare Pages / Netlify (_headers)
    Apache (.htaccess)
    Nginx

    Some browsers save .htaccess without its leading dot. If yours does, rename the file to .htaccess.

    What each header does

    01

    What it does

    A Content-Security-Policy built from presets, plus HSTS, Referrer-Policy, Permissions-Policy and more, for any server.

    • CSP builder with presets for common services
    • Report-only mode for safe testing
    • HSTS with preload warnings
    • Permissions-Policy, Referrer-Policy, nosniff and COOP

    02

    Private by design

    Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

    03

    What you get

    _headers, .htaccess and Nginx config, with a Copy and a Download button on every result.

    • CSP
    • HSTS
    • Security

    Why it matters

    Security headers are a few lines of server configuration that stop whole classes of attack: injected scripts, clickjacking, downgrades to unencrypted HTTP, and pages leaking their address to other sites. They cost nothing, but most small business sites send none of them.

    The Content-Security-Policy is the most powerful and the easiest to get wrong, because it must list every service your site loads from. Starting from a strict policy and ticking the services you use gets you most of the way, and report-only mode lets you test without breaking anything.

    How to use it

    1. Tick the services your site uses, then adjust any directive by hand.
    2. Set HSTS, Referrer-Policy and the browser features to switch off.
    3. Read the checks and fix anything in red.
    4. Copy the block for your server. Start in report-only mode, then switch it on.

    FAQ

    Will a CSP break my site?

    It can, if it misses a service you use. That's why there's a report-only mode: browsers report what would be blocked in the console without blocking it.

    Should I tick HSTS preload?

    Only once every subdomain works over HTTPS and you're sure you'll never need plain HTTP. Removal from the preload list takes months.

    Why not use 'unsafe-inline'?

    It allows any inline script to run, including injected ones, which removes most of the protection a CSP gives. Move scripts into files instead.

    How do I check my headers after publishing?

    Open your browser's developer tools, reload, and look at the response headers for the page, or use a free scanner such as Mozilla's HTTP Observatory.

    Work with me

    Want a site that gets these right?

    I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

    All developer tools · Back to leej.uk