Security Headers Generator: Configure CSP, HSTS and OWASP Headers the Easy Way
Learn how the free Security Headers Generator builds CSP, HSTS, X-Frame-Options and cross-origin headers, then exports ready-to-paste configs for nginx, Apache, Express, Caddy and Cloudflare Pages.
Table of Contents
Every time a browser loads your site, it quietly asks a question most developers never answer on purpose: "How much do you trust this response?" The answer lives in your HTTP response headers. A handful of them β Content-Security-Policy, Strict-Transport-Security, X-Frame-Options and friends β decide whether inline scripts run, whether the page can be framed by a third party, and whether browsers must talk to you over HTTPS only. Get them right and you shut down entire classes of attacks. Get them wrong, or leave them out, and you leave the door ajar.
The problem was never that security headers are hard to understand. It is that assembling a coherent set of nine headers, then translating them into the correct syntax for your web server, is tedious and error-prone. That is exactly the job of the free Security Headers Generator. You pick a preset, tweak the values you need, and copy a ready-made config block for nginx, Apache, Express, Caddy, Cloudflare Pages β or a plain raw header list. Everything runs 100% in your browser: no signup, no server round-trips, and nothing about your configuration ever leaves your machine.
In this guide we will walk through what each header does, how the tool's presets map to real deployment scenarios, and how to roll out a hardened header set without breaking your site in the process.
Why Use the Security Headers Generator?
- Covers the full OWASP-recommended set. The tool generates all nine modern security headers in one place: Content-Security-Policy, Strict-Transport-Security, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, plus the newer cross-origin trio COOP, CORP and COEP.
- Six output formats from one config. Toggle your headers once, then export them as an nginx add_header block, an Apache Header always set set, an Express middleware snippet, a Caddy header directive, a Cloudflare Pages _headers file, or a raw header list for anything else.
- Presets that match real situations. Strict, Balanced, Development and API / JSON presets give you a sane starting point instead of a blank page, whether you are hardening production or unblocking local dev.
- Copy-paste ready. Every output block is formatted the way the target platform actually expects it, so you spend seconds, not an afternoon fighting syntax errors in production config.
- Zero friction and zero cost. It is free, requires no account, and runs entirely client-side. Your security posture decisions stay private.
- An educational side effect. Because each header is listed with its value in an editable field, the tool doubles as a checklist that teaches you what a well-protected response looks like.
Key Features
| Feature | What it does |
|---|---|
| Quick Presets | One-click starting points: Strict, Balanced, Development, and API / JSON |
| 9 supported headers | The complete OWASP-aligned set including COOP, CORP and COEP |
| Per-header toggles | Enable or disable each header and edit its value freely |
| Multi-platform export | nginx, Apache, Express, Caddy, Cloudflare Pages _headers, and raw output |
| Copy button | Paste the generated block straight into your config or middleware |
| 100% in-browser | No signup, no uploads, no server-side processing at all |
Two details make daily use pleasant. First, the presets are opinionated but never lock you in β applying one fills the fields, and you can still adjust any single value before exporting. Second, the output panel regenerates live as you toggle headers, so you always see exactly what will be deployed, in the syntax of the platform you selected.
How to Use
- Open the Security Headers Generator and pick a Quick Preset that matches your scenario β Balanced is a good default for most sites, API / JSON if you are hardening an API.
- Review each header in the list. Disable anything you do not want yet, and edit values β for example, tune the HSTS max-age or add your analytics domain to the CSP.
- Switch the output format selector to your platform: nginx, Apache, Express, Caddy, Cloudflare Pages, or raw.
- Click the copy button and paste the block into your config file, server block, middleware, or _headers file.
- Deploy to staging, then scan your live site with a grader like securityheaders.com or Mozilla Observatory to confirm everything landed.
Understanding HTTP Security Headers
Each header controls one narrow behavior, and together they form layered defense:
- Content-Security-Policy (CSP) β the strongest anti-XSS control you can ship. It whitelists where scripts, styles, images and connections may come from. A policy like default-src 'self' blocks inline scripts and third-party assets unless explicitly allowed.
- Strict-Transport-Security (HSTS) β tells browsers to use HTTPS only, for a max-age you define. After the first trusted visit, plain-HTTP requests to your domain are upgraded or refused automatically.
- X-Frame-Options β DENY or SAMEORIGIN stops other sites from embedding your pages in an iframe, which kills classic clickjacking setups.
- X-Content-Type-options β nosniff prevents browsers from MIME-sniffing a response into an executable type.
- Referrer-Policy β controls how much URL detail leaks to other origins when users follow outbound links; strict-origin-when-cross-origin is the common choice.
- Permissions-Policy β a compact way to disable powerful browser features such as camera, microphone or geolocation across your site.
- COOP, CORP, COEP β the cross-origin trio that isolates your document, controls who can embed your resources, and gates cross-origin resource loading. Together they enable strong isolation against Spectre-class side-channel attacks.
The presets encode sensible combinations. Strict enables everything with hard-line values β ideal for a static site you fully control. Balanced keeps protection high while leaving room for common third-party integrations. Development relaxes the headers that break hot-reload and devtool workflows. API / JSON focuses on the headers that matter for machine-to-machine endpoints, where CSP and framing are mostly irrelevant but nosniff and HSTS still count.
Platform syntax is where hand-rolling configs usually goes wrong. nginx wants repeated add_header directives inside a server block, and by default they do not inherit into error responses unless you also set them at the right level. Apache uses Header always set lines inside your vhost or .htaccess. Express wants a small app.use middleware setting headers on res, which is also the shape helmet-style libraries generate. Caddy uses its clean header directive. Cloudflare Pages ignores all of the above and reads a plain-text _headers file at your project root. The generator emits the right shape for each, so the same toggles produce six different but equivalent outputs.
Practical Use Cases
Hardening a marketing site on Cloudflare Pages
You shipped a landing page on Cloudflare Pages and want an A grade before launch. Apply the Balanced preset, add your fonts and analytics hosts to the CSP value, choose the Cloudflare Pages output, and paste the _headers file into your project root. Commit, deploy, rescan β done in under five minutes.
Locking down an Express API
APIs rarely need CSP or frame protection, but they absolutely benefit from HSTS and nosniff. Choose the API / JSON preset, switch to the Express output, and drop the middleware into your app before your routes. Every JSON response now carries the right baseline headers.
Staged rollout without breaking production
Turning on a strict CSP on a live site overnight is asking for a broken checkout flow. Start with the Development or a relaxed custom set, watch your logs for blocked-resource errors, and progressively tighten values across deploys. The generator keeps each iteration a two-minute task instead of a config rewrite.
Protecting a web app from being framed
Your internal dashboard started appearing inside a partner's portal iframe and you want out. Enable X-Frame-Options with DENY, or use a Permissions-Policy / CSP frame-ancestors value for finer control, then export for whichever server fronts the app.
Best Practices
- Treat CSP as a ramp, not a switch. Start permissive, find violations in your logs, tighten, repeat. If you can use a report-only phase first, do it.
- Ramp HSTS max-age gradually. Begin with minutes, then hours, then days. A premature year-long max-age on a misconfigured domain is painful to walk back.
- Never copy-paste blindly. Presets are starting points. Read each value and confirm it matches how your site actually loads assets.
- Verify with an external grader. securityheaders.com and Mozilla Observatory show exactly what a browser receives β the source of truth after every deploy.
- Keep HTTPS everywhere first. HSTS and most protections assume TLS. Fix certificates before layering headers on top.
- Test in staging. Headers interact with proxies, CDNs and caches in surprising ways. Always promote through an environment that mirrors production.
Start Hardening Your Site Today
Security headers are the rare security fix that costs minutes, not weeks β as long as you do not hand-write six platform variants. Open the Security Headers Generator, pick a preset, and ship a hardened config for your stack before your next deploy. Your future self, and your next penetration test report, will thank you.
Related Tools You Might Like
- JWT Decoder β inspect and debug JSON Web Tokens in the browser, handy when you are auditing how your API authenticates requests.
- Base64 Encoder β encode and decode Base64 for tokens, data URLs and basic auth headers without reaching for a terminal.
- Password Strength Checker β test how resistant a password is to guessing and brute force before it guards anything important.
Happy hardening!