Skip to main content
L
Loopaloo
Buy Us a Coffee
All ToolsImage ProcessingAudio ProcessingVideo ProcessingDocument & TextPDF ToolsCSV & Data AnalysisConverters & EncodersWeb ToolsMath & ScienceGames
Guides & BlogAboutContact
Buy Us a Coffee
L
Loopaloo

Free online tools for developers, designers, and content creators. Your files are processed in your browser and are never uploaded - no accounts required. A few network utilities (like What's My IP and Currency Converter) call public APIs to do their job and say so on their pages.

support@loopaloo.com

Tool Categories

  • Image Tools
  • Audio Tools
  • Video Tools
  • Document & Text
  • PDF Tools
  • CSV & Data
  • Converters
  • Web Tools
  • Math & Science
  • Games

Company

  • About Us
  • Contact
  • Blog
  • FAQ

Legal

  • Privacy Policy
  • Terms of Service
  • Disclaimer

Support

Buy Us a Coffee

© 2026 Loopaloo. All rights reserved. Built with privacy in mind.

Privacy|Terms|Disclaimer
  1. Home
  2. Web Tools
  3. CSP Builder
Add to favorites

CSP Builder

Build a Content Security Policy from presets, see what browsers will really enforce, and copy it for nginx, Apache, Express or a meta tag.

Runs locally in your browserMore web toolsJump to full guide
Related readingContent Security Policy: Protecting Your Website from Injection Attacks10 min

Initializing in your browser…

You might also like

SRI Hash Generator

Create the integrity attribute and a ready-to-paste script or link element for a CDN file, or check an existing attribute against the file.

Password Generator

Make random passwords in one click, with the strength in bits calculated from the settings and the time each would take to guess.

Certificate Decoder

Decode any SSL/TLS certificate in your browser: issuer, dates, host names and extensions in plain words, with host checks and chain verification.

CSP Builder: a worked example

Your policy uses 'unsafe-inline' for a few inline scripts, and you are moving to a nonce so it can go. You add the nonce first, planning to remove 'unsafe-inline' afterwards.

The policy you wrote

script-src 'unsafe-inline' 'self' 'nonce-8emk/+h69qBbrg9F+Fbtaw=='
What CSP Builder produces

What a browser will actually apply, and why

script-src 'self' 'nonce-8emk/+h69qBbrg9F+Fbtaw=='

script-src  'unsafe-inline' in script-src is IGNORED, because this
            directive also carries a nonce or a hash. CSP Level 3
            section 6.7.3.2 discards it whenever either is present.
            Every inline script or style here must carry the nonce or
            match a hash, or it will be blocked. Keeping 'unsafe-inline'
            is still worth doing as a fallback for CSP Level 1 browsers,
            which ignore the nonce instead.

Adding the nonce tightened the policy before you removed anything. Modern browsers ignore 'unsafe-inline' as soon as a nonce or hash appears in the same directive, so every inline script without the nonce attribute stops running the moment the new policy ships. The builder shows the effective policy for exactly this reason. The same check lists what else this one-line policy leaves open: no default-src, and no base-uri, form-action, frame-ancestors or object-src.

About the CSP Builder

Build a Content Security Policy from presets or directive by directive, and see what a browser will really enforce, including the rules that silently ignore parts of what you wrote. Get it as an HTTP header, nginx, Apache, Express or Netlify configuration, or a meta tag, with nonces and inline hashes built in.

Key features

  • Four presets, from strict nonce-based to report-only
  • Every CSP Level 3 directive, grouped by purpose
  • The effective policy a browser applies, shown beside yours
  • Findings for ignored sources, missing fallbacks and meta-only limits
  • Unquoted keywords corrected automatically
  • Nonce generator and SHA-256, 384 and 512 inline hashes
  • Output for HTTP headers, nginx, Apache, Express, Netlify and meta tags
  • Runs in your browser

How to use

  1. 1Pick a preset, or start empty and tick the directives you need.
  2. 2Choose keywords and schemes for each directive, or type your own origins.
  3. 3Choose header or meta delivery, and enforce or report-only mode.
  4. 4Read the findings and the effective policy, and fix anything flagged.
  5. 5Copy the policy in the form your server uses.

Writing a policy that does what it says

What a CSP is for. A Content Security Policy tells the browser where a page may load scripts, styles, images, fonts and other resources from, and whether inline code may run. If an attacker manages to inject a script tag into your page, a good policy stops it from running. It is one of the strongest defences against cross-site scripting.

Start from a preset. The strict preset uses a nonce with 'strict-dynamic', the arrangement the specification recommends: scripts carrying the nonce run, and scripts they load are trusted in turn, so you do not have to list every CDN. The allowlist preset needs no nonce but blocks all inline scripts. The report-only preset blocks nothing and reports everything, which is the safe way to see what a real site does before enforcing a policy.

The rules that surprise people. Several decisions are made silently by the browser. A nonce or hash in a directive makes 'unsafe-inline' in that directive be ignored. 'strict-dynamic' makes host and scheme sources and 'self' be ignored. frame-ancestors, form-action, base-uri and sandbox are not covered by default-src, so leaving them out leaves them open. frame-ancestors, report-uri, report-to and sandbox do nothing in a meta tag. A keyword typed without quotes, such as self, is read as a host name and allows nothing. The builder applies each rule, shows the policy a browser will actually enforce when it differs from the one you wrote, and explains every finding.

Nonces and hashes. A fresh 128-bit nonce is generated for you; your server must create a new one for each response and add it to every inline script. To allow one fixed inline script or style without a nonce, paste it in and add its SHA-256, 384 or 512 hash to script-src or style-src.

Ready to paste. The finished policy comes as a header line and as nginx, Apache, Express and Netlify configuration, plus a meta element when you choose meta delivery. Everything runs in your browser.

Examples

  • Moving from unsafe-inline to a nonce

    Add the nonce to script-src and keep 'unsafe-inline' as a fallback for very old browsers; the builder shows that modern browsers then ignore 'unsafe-inline'.

  • Stopping clickjacking

    Set frame-ancestors to 'none' or 'self' and deliver the policy as a header, since browsers ignore frame-ancestors in a meta tag.

  • Trying a policy safely

    Start with the report-only preset and a report-uri, collect reports for a while, then switch to enforce once nothing legitimate is being blocked.

Tips & best practices

  • Always set object-src 'none' and base-uri 'self' or 'none'; they close two common bypasses.
  • Roll out in report-only mode first and watch the reports for a week before enforcing.
  • Prefer nonces or hashes to 'unsafe-inline' for scripts; inline styles are lower risk.
  • Keep the policy in one place in your server configuration so every response gets it.

Frequently asked questions

Should I use a header or a meta tag?

A header whenever you can. A meta tag cannot use frame-ancestors, report-uri, report-to or sandbox, and cannot be report-only. Use a meta tag only on hosting where you cannot set headers.

Why is 'unsafe-inline' shown as ignored?

When a directive also contains a nonce or a hash, modern browsers ignore 'unsafe-inline' in it. Older browsers that do not understand nonces still use it, so keeping both is a reasonable transition.

What does 'strict-dynamic' do?

It lets scripts that carry your nonce or hash load further scripts, and makes the browser ignore host lists and 'self' in that directive. It suits sites that load scripts from many places at run time.

Can I reuse the nonce shown here?

Not in production. The nonce must be random and different on every response, or an attacker can read it from one page and use it on another. Use the generated value to test, and have your server create its own.

What is report-only mode?

The browser reports what the policy would block without blocking it. It sends reports to the address in report-uri or report-to, so set one, or the mode records nothing.

Why does a missing default-src matter?

default-src is the fallback for most fetch directives. Without it, any type you did not list, such as images or fonts, can load from anywhere.

Related tools and how they differ

  • SRI Hash Generator: Adds integrity hashes to scripts and styles from a CDN, which pairs well with a strict policy.
  • Meta Tag Generator: Builds the other tags for the page head, where a meta policy also goes.
  • URL Safety Analyzer: Checks the links you are about to allow, on the visitor side of the same problem.

Further reading

  • Content Security Policy: Protecting Your Website from Injection Attacks10 min read

Private by design

This runs as client-side JavaScript. Keys, tokens, payloads, and other inputs never leave your device.