CSP Builder
v1.0The CSP Builder is the second tool in the Developer & Web section. You can build a Content-Security-Policy from directive rows, or paste an existing policy to have it split apart and checked.
Build mode starts from a sensible defensive policy. Three presets cover common cases: Google's strict CSP (a per-response nonce plus 'strict-dynamic'), a locked-down static site, and a Next.js app with the allowances it needs. Anything that uses a nonce gets a real one generated when you click, and every row has its own Generate button. Loading a preset replaces the whole policy, and a toast lets you undo for a few seconds.
Each directive row has an editor suited to it. Source directives get one-click keyword chips for 'self', 'none', 'unsafe-inline', 'unsafe-eval' and 'strict-dynamic', common schemes like https:, data: and blob:, a field for hosts, and nonce and hash builders that write the correct 'nonce-…' or 'sha256-…' (or 384/512) syntax. report-to, report-uri, sandbox, trusted-types and require-trusted-types-for get token chips instead. An empty sandbox is kept, because it's the most restrictive form.
The output can be the enforcing Content-Security-Policy header, Content-Security-Policy-Report-Only, or a <meta http-equiv> tag. Report-only is the safe way to roll out a policy, and a report-only policy with no report-to or report-uri is flagged because it would collect nothing. The panel shows the size in bytes and warns past 4 KB, ahead of the 8 KB limit many servers apply to a header. With the meta tag, it warns when the policy has header-only directives like frame-ancestors or report-uri, because a meta tag ignores them.
Parse mode takes any policy (from a live site, a scanner or a message), splits it into directives and sources, and checks it. One click loads it into the builder so you can fix it. The checks cover 'unsafe-inline' and 'unsafe-eval', wildcard hosts, a missing object-src or base-uri, repeated directives (only the first applies), unrecognized names, and no script-src or default-src fallback. They also catch policies that mean the opposite of what they look like: 'strict-dynamic' with no nonce or hash, 'none' mixed with other sources, and http:// sources under upgrade-insecure-requests. 'unsafe-inline' next to a nonce is reported as a fallback for older browsers, not as a hole.
Warnings appear live in build mode, next to the row you changed. Share puts the whole policy and mode in a link, and your rows are remembered between visits.