Free Content Security Policy Checker and CSP Header Analyser
Paste a CSP header or meta tag to see each directive and its fallback, test an address against it and copy a tightened policy. It all runs in your browser.
Last updated 15 November 2026
This content security policy checker reads a policy you paste and explains what a browser would do with it. MDN describes the Content-Security-Policy response header as a way for site administrators to control the resources a browser is allowed to load for a page, which helps guard against cross-site scripting. Paste a bare policy, a whole Content-Security-Policy or Content-Security-Policy-Report-Only header line, or a meta element, and the tool says which it recognised. It parses the policy as the W3C Content Security Policy Level 3 specification does, shows each directive in a tree beside the directive it falls back to, and lists findings that each name the source and section they rest on. You can test an address against the policy, then copy a tightened version as a report-only header, with every change explained. Nothing you paste or type leaves the page.
How to use this tool
- 1
Paste the policy
Paste a policy value, a Content-Security-Policy or Content-Security-Policy-Report-Only header line (a block of response headers works too), or a meta element with http-equiv="Content-Security-Policy". Up to 20,000 characters.
- 2
Check the policy
Press Check policy. The tool says what it read the paste as and how many directives apply, then lists its findings with the most serious first.
- 3
Open the directive tree
Each fetch directive sits under the directive it falls back to. Open one to see what it controls, its fallback order and the sources that apply. Directives with no fallback to default-src are listed separately.
- 4
Test an address
Type the address of the page that sends the policy, choose a resource type and type the address to test. Press Test address to see whether the policy would match it and which directive decided.
- 5
Copy the tightened policy
Read each change and what was left for you to decide, copy the report-only header and send it first, then send the enforced header once the reports show nothing you need is blocked.
How a browser reads the Content-Security-Policy header
The W3C Content Security Policy Level 3 specification, a Working Draft that asks to be cited only as a work in progress, sets out how a browser turns header text into a policy. The value is split on semicolons into directives. Each directive starts with its name, which is compared without regard to letter case, so script-SRC and script-src are the same directive, and the rest of the directive, split on whitespace, is its list of sources. If a name appears a second time in one policy, the second copy is ignored. The specification suggests that browsers warn developers about it, for example in the console, and the rest of the policy still applies, so a source added to the second copy simply has no effect. A comma means something different. In the header grammar a comma separates one policy from the next, and a response can carry several Content-Security-Policy headers. The specification says the browser must enforce each policy it receives, and its note on multiple policies says that adding policies to enforce can only further restrict what the page can do: a request has to pass all of them. Where the policy is delivered matters as well. The OWASP Content Security Policy Cheat Sheet calls the response header the preferred way to deliver a policy. A meta element whose http-equiv is Content-Security-Policy works for most directives, but the specification says it cannot carry frame-ancestors, report-uri or sandbox, that the report-only header is not supported in a meta element, and that a policy in a meta element is not applied to content that comes before it. This checker applies the same parsing rules, reads a meta element's content as a single policy, and says which form it recognised, so a repeated directive, or a header-only directive in a meta tag, shows up as a finding.
Fallbacks: what default-src covers, and what it never covers
Most fetch directives fall back to another directive when the policy leaves them out, and the specification lists the order for each one. A script element is checked against script-src-elem, then script-src, then default-src, and the first of those the policy contains decides. Inline event handlers follow script-src-attr, then script-src, then default-src. Stylesheets and style attributes do the same with the style-src family. Frames go frame-src, child-src, default-src, and workers go worker-src, child-src, script-src, default-src. Images, fonts, media, manifests, plugin content and connections each fall back straight to default-src. MDN puts it the same way: default-src is a fallback for all other fetch directives. There is no inheritance. The specification says that once script-src is set, default-src has no influence on script requests, so with default-src 'self' and script-src https://cdn.example.com, a script from your own origin is not allowed. A directive that is missing, with nothing set to fall back to, places no limit at all, and the specification notes that a policy without default-src cannot mitigate exfiltration. Some directives are on no fallback list. The specification's list names only fetch directives, so base-uri, form-action and frame-ancestors, along with sandbox and the reporting directives, are untouched by default-src. Its note on frame-ancestors is direct: a policy that declares default-src 'none' will still allow the resource to be embedded by anyone. The specification also describes a good way to build a policy: begin with default-src 'none' and allow only the resource types the page needs. The directive tree in this tool follows these lists. Open any directive to see where its sources come from, or that nothing restricts it.
Reading source expressions, and what the findings point at
Each directive's value is a list of source expressions. MDN says host and scheme sources are written without quotes and every other form goes in single quotes, so self on its own is read as a host called self, not as the 'self' keyword. A host source can carry a scheme, a port and a path. A leading *. matches subdomains but not the bare domain, a source with no port matches only the default port for the address's scheme, a path ending in / matches anything below it, and any other path must match exactly. A scheme source such as https: matches any resource having that scheme, and a bare * matches any address whose scheme is http or https, or the page's own scheme. The specification lets an http source match https as well, and says this stops a page from locking itself into insecure addresses. Some keywords change what else in a list counts. MDN says developers should avoid 'unsafe-inline' and 'unsafe-eval', because each defeats much of the purpose of having a CSP, and the specification says developers should not include 'unsafe-inline' or data: as sources, because both let code be included directly in the document. A nonce or hash in the same list makes a browser ignore 'unsafe-inline'. With 'strict-dynamic', MDN says host sources, scheme sources, 'self' and 'unsafe-inline' are ignored, and the trust a nonce or hash gives a script extends to the scripts it loads. The specification asks developers who use it to audit the places their code inserts scripts, in case untrusted data can reach them. Nonces carry their own rules: the specification says they must remain unguessable, because bypassing the policy is otherwise trivial, and that the server must generate a unique value each time it sends a policy. Each finding in this tool names the specification section, MDN page or OWASP cheat sheet section it rests on. A finding marked Matches has the value its cited source sets or recommends, and none of them is a verdict on the policy as a whole.
Tightening a policy, and testing it in report-only mode first
The tightened policy this tool writes changes only what it can change without knowing your site. In the lists that govern script, it removes 'unsafe-inline' when no nonce, hash or 'strict-dynamic' already overrides it, removes 'unsafe-eval', and removes data: unless 'strict-dynamic' is present. When default-src is the list for script, it adds a script-src with the same sources less those. Workers check worker-src, then child-src, then script-src, then default-src, so when the policy sets neither worker-src nor child-src it also adds a worker-src with default-src's sources. Images, fonts, workers and the other types that fell back to default-src keep the list they had. It drops repeated directives and directives with characters outside ASCII, because the specification's parser ignores them. Then it adds what the policy leaves out: object-src 'none' (unless default-src is already 'none') and base-uri 'none', which both strict policy samples in the OWASP cheat sheet set, then frame-ancestors 'self' and form-action 'self', which have no fallback to default-src. Anything that depends on what your pages load, such as a * in script-src or a missing default-src, is listed for you to decide rather than guessed. Each change can block something a page uses today, which is why the tool writes a Content-Security-Policy-Report-Only version beside the enforced one. The specification describes the report-only header as a way to experiment by monitoring a policy rather than enforcing it: deploy a report-only policy, watch the violation reports, and move to an enforced policy once you are confident in its behaviour. The OWASP cheat sheet says report-only is often used before a policy is enforced in blocking mode. MDN says report-to must be set for a report-only policy's reports to be sent, with the endpoint named in a Reporting-Endpoints header. Without it, OWASP says violations are still printed to the browser console. When the reports show nothing you need is blocked, send the same policy in the enforced header.
What this checker does with your policy, and where it stops
The checker runs in this page. The policy you paste and the addresses you type are parsed as text in your browser; nothing is uploaded, and the tester never requests an address. Pasted text can be up to 20,000 characters and each address up to 2,048, and anything longer is refused rather than cut, so a result always covers the whole paste. A header value with several comma-separated policies, or a paste with several header lines, gets its first policy analysed and a count of the rest. A meta element's content is read as one policy, and only numeric and ten named character references ending in a semicolon are decoded. Long results are bounded too: the findings list shows the 60 most serious, each directive in the tree lists up to 40 sources, and the tool says whenever it leaves something out. The scenario tester follows the specification's matching for scheme, host, port and path, and its fallback lists. It does not model redirects, nonces or hashes carried by the element itself, the scripts that 'strict-dynamic' lets a trusted script load, other policies sent with the same page, or how a particular browser implements the specification. Where one of those decides the outcome, as with 'strict-dynamic', the tester says so instead of guessing. Where the specification disagrees with itself, for IP address hosts and a port 80 source against https, the tester follows the matching algorithm and says so. Some things no paste can show. The tool sees one copy of the policy, so it cannot tell whether a nonce changes with every response. It cannot see which scripts and styles your pages load, so it cannot tell whether the tightened policy will break them; a report-only run shows that. It does not look for the injection flaws a policy is there to contain. The OWASP cheat sheet calls a strong CSP an effective second layer of protection, especially against XSS, and says it should not be relied on as the only defence: good development practices come first, with CSP deployed on top as a bonus security layer.
Sources
- W3C: Content Security Policy Level 3 (W3C Working Draft)
- WHATWG: HTML Standard: pragma directives, Content security policy state
- WHATWG: HTML Standard: fetching scripts, fetch a classic worker script
- MDN Web Docs: Content-Security-Policy (CSP) header
- MDN Web Docs: Content-Security-Policy-Report-Only header
- OWASP Cheat Sheet Series: Content Security Policy Cheat Sheet
Worked example
An invented example, not taken from any site: a policy for www.example.com.au that loads scripts from its own origin and one CDN, and still allows inline script.
- Pasted policy
- Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.example.com; img-src 'self' data:
- Page address
- https://www.example.com.au/
- Addresses tested
- https://cdn.example.com/widget.js as a script, and https://video.example.net/embed/1 as a frame
Read as a Content-Security-Policy header line with 3 directives applied. The findings: 'unsafe-inline' in script-src allows inline script, there is no base-uri, no frame-ancestors and no form-action, and object-src falls back to default-src. The script address is allowed by script-src. The frame address is blocked by default-src, because frame-src and child-src are not set.
The tightened policy removes 'unsafe-inline' from script-src and adds object-src 'none', base-uri 'none', frame-ancestors 'self' and form-action 'self'. The developer adds a report-to endpoint, sends the policy as a report-only header, moves each inline script the reports name into a file, and adds frame-src https://video.example.net for the embedded player before sending the enforced header.
Who uses this tool
Developers writing a first policy
Paste a draft to see which resource types fall back to default-src, which have no limit at all, and which directives with no fallback are still missing.
Teams moving to an enforced policy
Check the policy you plan to enforce, confirm the report-only version has a report-to endpoint, and copy both headers with each change explained.
Reviewers checking a generated header
Paste the header a framework or middleware sends and test the addresses of the scripts, fonts, frames and APIs the site uses against it.
Site owners reading a policy for the first time
See what each directive does in plain English, with the specification section, MDN page or OWASP cheat sheet section behind every finding.
Frequently asked questions
Does this CSP checker fetch my site or send my policy anywhere?
No. The policy you paste and the addresses you type are parsed in your browser and never uploaded, and the scenario tester compares addresses as text without requesting them. To check a live site, copy its Content-Security-Policy header from your browser's developer tools and paste it here. When a check runs, the page sends one analytics event that names the tool and the page, and nothing from your input.
Why can other sites still frame my page when default-src is 'none'?
Because frame-ancestors has no fallback. The specification says frame-ancestors will not fall back to default-src, so a policy that declares default-src 'none' will still allow the page to be embedded by anyone. Add frame-ancestors 'self', or 'none' if nothing should frame the page, and send it in a response header, because the specification says it is ignored in a policy delivered by a meta element.
Is 'unsafe-inline' still active if my policy also has a nonce?
Not in a browser that supports nonces. MDN says that when a directive contains a nonce or a hash as well as 'unsafe-inline', the browser ignores 'unsafe-inline', and 'strict-dynamic' has the same effect. The specification's section on 'strict-dynamic' describes listing it for backwards compatibility: a policy like that acts as 'unsafe-inline' only in browsers that support Content Security Policy Level 1.
What does 'strict-dynamic' change in a script-src?
MDN says it extends the trust a nonce or hash gives a script to the scripts that script loads, and that host sources, scheme sources, 'self' and 'unsafe-inline' in the same directive are ignored. In this tool's scenario tester, the address then cannot decide the outcome for a script element on its own: that depends on the element's nonce or hash, or on whether a running script inserted it, so the tester says so instead of guessing.
Should the policy go in a response header or a meta tag?
A header where you can. The OWASP cheat sheet calls the Content-Security-Policy header the preferred way to deliver a policy. The specification says a meta element cannot carry frame-ancestors, report-uri or sandbox, cannot deliver a report-only policy, and does not apply to content that comes before it in the page. If your host only lets you edit HTML, a meta element placed early in the head still carries the other directives.
Why test the tightened policy in report-only mode first?
Because each change can block something your pages use today. The specification describes deploying a report-only policy, watching the violation reports and moving to an enforced policy once you are confident in it, and MDN says the report-only header lets you test or repair violations before a policy is enforced. Add report-to with an endpoint first: MDN says reports are not sent without it.