Skip to content

Menu

CSP Builder

Visual Content-Security-Policy header builder with directive toggles.

Runs entirely in your browserAuth & SecurityFree, no sign-up
Loading tool

01What is CSP Builder?

Writing a Content-Security-Policy by hand is fiddly. One missing quote or stray comma and the browser quietly ignores part of it. CSP Builder puts the policy together from checkboxes instead. It offers fourteen directives: default-src, script-src, style-src, img-src, font-src, connect-src, media-src, object-src, frame-src, frame-ancestors, base-uri, form-action, worker-src and manifest-src. Each has buttons for the common values ('self', 'none', https:, data:, blob:, 'unsafe-inline', 'strict-dynamic' and so on). There is also a box for your own hosts, such as https://cdn.example.com. You can switch on upgrade-insecure-requests too. Two reporting fields are available. report-uri is the older form and takes a URL. report-to is the CSP Level 3 form and takes an endpoint name. That name must be defined in a separate Reporting-Endpoints header, which the tool writes for you when you fill in both. The header updates as you click. Copy it as a Content-Security-Policy header line or as a meta tag. The meta version leaves out frame-ancestors, report-uri and report-to, because the CSP spec says browsers ignore those in a meta policy, and the tool tells you when that happens. Anything you type that contains a semicolon, comma or quote is left out, since it would split or break the header. A warnings panel flags common mistakes. It catches 'unsafe-inline' or 'unsafe-eval' in scripts, wildcard script sources and 'none' mixed with other sources (which cancels it). It also warns about 'strict-dynamic' without a nonce or hash, which blocks every script. A missing object-src or base-uri gets a nudge, and so does the deprecated block-all-mixed-content. Here is a quick example. Keep default-src at 'self', tick object-src with 'none' and base-uri with 'self', and the output is default-src 'self'; object-src 'none'; base-uri 'self' and the warnings panel is empty. Directives always print in the tool's fixed order, not the order you clicked them. The nonce button inserts a 'nonce-{random}' placeholder on purpose. A nonce has to be a fresh random value generated by your server for every response, so a static page can't produce one for you. The builder also doesn't add hash sources, and it doesn't test the policy against your site. For that, ship it as Content-Security-Policy-Report-Only first and watch what breaks.

Frontend and security-minded developers use it to draft a first Content-Security-Policy header or meta tag without hand-typing directive syntax. The tool runs entirely in your browser, so your data never leaves your device.

02How to use CSP Builder

  1. Leave default-src on with 'self' as the baseline.
  2. Tick the directives you need and click the common values, or type your own hosts separated by spaces.
  3. Add report-uri and, if you want the newer API, a report-to endpoint name.
  4. Read the warnings panel and fix anything that weakens the policy.
  5. Copy the header line (or the meta tag) and, if shown, the Reporting-Endpoints header, then add them to your server or framework config.

03Worked examples

Input: Defaults: default-src 'self' only
Result: default-src 'self' Warnings: Consider object-src 'none' to block plugin content…; Consider base-uri 'self' or 'none': base-uri does not fall back to default-src…
base-uri is one of the directives that default-src does not cover.
Input: default-src 'self', plus object-src 'none' and base-uri 'self'
Result: default-src 'self'; object-src 'none'; base-uri 'self' Warnings: none
Adding object-src and base-uri clears the two suggestions shown for the defaults.
Input: default-src 'self'; script-src 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'
Result: default-src 'self'; script-src 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self' Warning: 'unsafe-inline' for scripts allows injected inline scripts and removes most XSS protection. Use a nonce or hash instead.
Input: script-src 'nonce-{random}' 'strict-dynamic', plus default-src 'self', object-src 'none', base-uri 'none'
Result: default-src 'self'; script-src 'nonce-{random}' 'strict-dynamic'; object-src 'none'; base-uri 'none' Warning: Replace {random} with a fresh, unguessable value (at least 128 bits, Base64) generated by your server for every response…
No 'strict-dynamic' warning here because a nonce is present.
Input: default-src 'none'; img-src 'self' with custom value "https://cdn.example.com bad;value"; object-src 'none'; base-uri 'self'
Result: default-src 'none'; img-src 'self' https://cdn.example.com; object-src 'none'; base-uri 'self' Warning: img-src: values containing ; , or " were left out because they would break the header.
Directives are always printed in the tool's fixed order, not the order you enabled them.

04Common use cases

  • Drafting a first Content-Security-Policy for a new web app before testing it in report-only mode
  • Turning a list of CDN, analytics and API hosts into correctly formatted source lists
  • Starting a nonce-based strict policy with 'strict-dynamic', object-src 'none' and base-uri 'none'
  • Adding reporting with both report-uri and report-to so all browsers send violation reports
  • Producing a meta tag policy for a static site on a host that won't let you set response headers
  • Locking down a page that should never be framed by setting frame-ancestors 'none'
  • Allowing an embedded YouTube or map iframe through frame-src without opening up script-src

05Tips

  • Deploy new policies as Content-Security-Policy-Report-Only first, read the reports, then switch to enforcing
  • Prefer nonces or hashes for inline scripts over 'unsafe-inline'; with a nonce present, modern browsers ignore 'unsafe-inline' anyway
  • connect-src covers fetch, XMLHttpRequest, WebSocket and EventSource, so a missing API host there shows up as failed requests
  • frame-ancestors only works in the HTTP header; use it instead of X-Frame-Options to control who can embed your pages
  • A meta tag policy only applies to content loaded after the tag, so put it as early in the <head> as you can.

06Related concepts

CSP Level 3, XSS prevention, Nonce-based CSP, Report-URI.

Frequently Asked Questions

What is CSP Builder?

CSP Builder is a free, browser-based developer tool on AIDToolStack. Visual Content-Security-Policy header builder with directive toggles. It requires no installation or sign-up and works entirely in your browser.

Is CSP Builder free to use?

Yes. No sign-up, no fees and no usage cap.

Does CSP Builder store my data?

No. It runs in your browser; nothing is uploaded.

Cheat sheet

Related Tools

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe