What Is Content Security Policy Builder?
Content Security Policy Builder is a free online tool by TechnSols that builds a Content-Security-Policy header from a form. Pick a preset or fill in the directives one by one, and the tool joins them into a single header string that is ready to copy into a server configuration, plus the matching meta tag for pages that need one. It answers the simple question of how to write a correct CSP header without memorising the directive names or the quoting rules.
A Content-Security-Policy header tells the browser which sources of scripts, styles, images, fonts, frames and other resources are allowed to load on a page, and the browser blocks anything that is not listed. It is a strong defence against cross site scripting, because even when an attacker injects a script, the policy stops the browser from running it. Writing the header by hand is error prone: a missing quote or a forgotten directive can leave the policy open or break the page entirely. The builder writes the string correctly and warns about risky choices as it goes. It is different from the HTTP Header Checker tool, which fetches live headers from a URL, while this tool builds a new header from scratch.
The tool builds the header string only. It does not test a live site, it does not apply the policy to any page, and it never sends a request. Fill in the form, press the button, copy the header, and paste it into the server configuration. Nothing leaves the browser at any point.
How To Use Content Security Policy Builder?
Using Content Security Policy Builder takes a few minutes, with no software to install and no account to make. The only input is text, so the tool works on any device with a browser.
Step 1: Pick A Preset Or Fill In The Directives
Start with the Balanced preset, which allows the site itself for most content and blocks plugins entirely, or pick Strict for a tighter policy. Then edit any directive field that needs a different value, such as adding a CDN host to script-src or an API host to connect-src. Each field holds the sources for one directive, written as keywords such as self and none, or as host names. When the rules that govern crawling of the same site also need work, the Robots.txt Generator tool builds the rules file.
Step 2: Press Build CSP Header And Read The Warnings
Press Build CSP Header and read the result. The first line is the full header, ready to copy, and the second line is the matching meta tag. Any warning appears below, such as a note that style-src allows unsafe-inline, that a directive allows any source with a wildcard, or that object-src is not set. A warning is advice, not an error, and the header is still built.
Step 3: Copy The Header And Deploy It
Press Copy Header to copy the full header string, then paste it into the server configuration, a reverse proxy rule or a framework setting. Deploy it in report only mode first, watch the violation reports for a few days, and only then switch to the enforcing header. Press Download on the result row to save a text file with the header, the meta tag and the warnings for the deployment notes.
Why Use Content Security Policy Builder?
A CSP header is a single long string, and one small mistake in it can undo the whole policy or break the site. Building it in a form, with each directive in its own field, removes the mistakes that hand written headers invite.
One String Carries The Whole Policy
A policy can hold a dozen directives, each with several sources, all joined into one header value with semicolons. Writing that by hand means keeping the directive names, the quotes and the semicolons all correct at once, and a single slip can turn a strict policy into an open one. The builder joins the directives in a fixed order and adds the semicolons itself. When the site also ships a web app manifest, the PWA Manifest Inspector tool validates the pasted manifest in the same way.
Risky Choices Are Flagged At Once
Allowing unsafe-inline in script-src or a wildcard in any directive weakens the policy, and the weakness is easy to miss in a text editor. The builder warns about unsafe-inline, unsafe-eval and wildcards as soon as the header is built, so the risk is seen before the policy ships. A policy with no warnings is a stronger starting point than a policy whose risks were never checked.
Report Only Mode Makes Rollout Safe
Switching a strict policy on without testing can block scripts and fonts that the site needs, and the breakage only shows up in production. The report only checkbox changes the header name to Content-Security-Policy-Report-Only, which logs violations without blocking anything, so the policy can be tested against real traffic first. The CSP reference guide page explains the report only mode and every directive in full.
What Can You Do With Content Security Policy Builder?
The builder fits anywhere a CSP header has to be written, tightened or explained, from a new project to a security audit and a framework migration.
Write A First Policy For A New Site
A new site needs a policy that allows its own scripts, styles, images and fonts and blocks everything else, and the Balanced preset is that policy. Build it, copy it, deploy it in report only mode, and tighten it once the reports show what the site really loads. When the structured data on the same site also needs a check, the JSON Schema Validator tool checks pasted data against its schema.
Tighten A Policy That Allows Too Much
A policy that allows unsafe-inline everywhere or a wildcard for scripts gives almost no protection, and removing those allowances one at a time is the usual path to a strong policy. Build the current policy in the form, remove one risky source, rebuild, and check the warnings until none are left. Each rebuild shows the exact header that will ship, so nothing is deployed untested.
Explain A Policy To A Team Or A Client
A policy written as one long header string is hard to explain in a meeting, while the same policy shown directive by directive is easy to walk through. The form shows each directive in its own field, and the result lists the header and the warnings beside it, which makes the policy reviewable by anyone. When the page the policy protects also needs its structure checked, the HTML Element Inspector tool shows the element tree of the page.
Quality And Settings
The builder has no quality setting to tune, because building a header is exact work rather than a matter of taste. The settings that matter are the directive values themselves, and the tool uses them exactly as typed, without changing a character.
- Directives are joined in a fixed order, from default-src to report-to, so the same form always builds the same header.
- Empty directive fields are left out of the header, so a policy only states what the form actually sets.
- Keywords keep their single quotes, such as self and none, because the browser requires them.
- The meta tag leaves out frame-ancestors, report-uri and report-to, because browsers ignore those directives in a meta tag.
- The report only checkbox changes only the header name, so the policy itself stays identical in both modes.
When no directive has a value, the error message says so and asks for at least one directive, such as default-src with the value self. Compare the built header with the form values before deploying it.
How Content Security Policy Builder Works?
The tool reads the twelve directive fields in a fixed order and joins every field with a value into one string, each directive followed by its sources and a semicolon. The header name is Content-Security-Policy, or Content-Security-Policy-Report-Only when the report only box is checked. The meta tag is built from the same values, leaving out the three directives browsers ignore in a meta tag, and the result says so in a note.
Each directive value is then checked for risky patterns: the keywords unsafe-inline and unsafe-eval, a wildcard source, and a data source inside script-src. An empty default-src or an empty object-src also earns a warning, because unset types fall back to default-src and plugins fall back with them. The Website Link Crawler tool follows the same build and check pattern for links inside a page, and the OWASP secure headers page lists the recommended headers that a CSP should sit beside.
Privacy
Content Security Policy Builder runs entirely in the browser. The directives that are typed and the header that is built never leave the device, and nothing is uploaded to a server or stored anywhere. There is no account and no tracking, and closing the page clears everything. When the server answer for the same site also needs a local check, the HTTP Status Code checker explains what each code means, with everything running locally and nothing sent away.
Because nothing is stored, there is also nothing to delete and nothing to export. The downloaded text file is the only record, and it lives wherever the browser saves downloads. A policy can still reveal infrastructure detail, such as CDN host names, so the downloaded file should be shared with the same care as the server configuration.
Tips
A few habits make CSP headers much easier to work with, and they cost nothing to adopt.
- Deploy in report only mode first and read the violation reports before enforcing anything.
- Keep default-src as the fallback and set the other directives only where they differ from it.
- Set object-src to none on every site, because plugins are rarely needed and often abused.
- Remove unsafe-inline from script-src before launch, and use a nonce or a hash for the inline scripts that remain.
- Test with the Balanced preset before editing, so the shape of the result is familiar when real values are typed.
When a policy breaks a page, the browser console names the directive that blocked each resource, and that directive is the one to fix first. For a check of the mail headers of the same domain, the EML Header Parser tool reads routing headers the same way, and the URL Parser tool breaks down the report endpoint address used by report-uri.
More Tools For The Same Job
The tools below solve the jobs that sit next to content security policy on the same bench.
- HTTP Header Checker: fetches live headers from a URL and reports what the server sends.
- Robots.txt Generator: builds a robots.txt file that tells crawlers what they may fetch.
- PWA Manifest Inspector: validates a pasted PWA manifest and reports errors.
- MIME Header Inspector: parses pasted MIME headers and shows the MIME structure behind them.
- HTTP Header Formatter: turns pasted raw HTTP headers into a readable table with plain language notes.
- JSON Schema Validator: checks pasted JSON against a schema and reports mismatches.
- Robots.txt Rule Tester: tests pasted robots.txt rules against URLs and reports allowed or disallowed.
- Web Manifest Editor: edits PWA manifest fields in a form and downloads the manifest file.
- HTML Element Inspector: shows the element tree of pasted HTML.
- Structured Data JSON-LD Validator: checks pasted JSON-LD against schema.org types and required fields.
FAQ
The questions below cover the points that come up most often when a content security policy is built for the first time.
What Is A Content Security Policy?
A content security policy is a header that tells the browser which sources of scripts, styles, images, fonts, frames and other resources may load on a page. Anything not listed is blocked. It defends against cross site scripting, because an injected script from an unlisted source cannot run, even when the injection itself succeeds.
Where Do I Put The Header?
Put the header in the server configuration, such as the web server settings, a reverse proxy rule or a framework middleware, so it is sent with every HTML response. A meta tag works as a fallback on pages where the server cannot be changed, but it cannot carry frame-ancestors or report-uri, so the real header is always the better choice.
What Does Unsafe Inline Do?
Unsafe-inline in script-src allows inline scripts to run, which is convenient for small sites but weakens the policy, because an injected inline script is then allowed too. Removing it means every inline script needs a nonce or a hash instead. The builder warns whenever unsafe-inline appears, so the trade off is seen before the policy ships.
Should I Use Report Only Mode First?
Yes, always deploy a new or tightened policy in report only mode first, and watch the violation reports for a few days. The reports show which resources the policy would have blocked, including scripts and fonts the site genuinely needs. Fix the policy from those reports, and only then switch to the enforcing header.
Is Content Security Policy Builder By TechnSols Free?
Yes, Content Security Policy Builder by TechnSols is completely free to use online, with no sign up, no install and no limit on the number of policies built. It runs in the browser, nothing is uploaded, and the text file downloads free too. The tool works the same way on every visit, with no account and no payment step.
A strong policy starts as a short header built one directive at a time, and the builder keeps that process simple for every site, from a first draft to a strict policy. Build it, test it in report only mode, enforce it, and keep it tight.