Content-Security-Policy generator for Google Maps

Paste your site's current Content-Security-Policy, choose a style, and copy back a policy with the sources the Maps JavaScript API needs merged in. It runs in your browser; your policy isn't sent anywhere.

Policy style
Content-Security-Policy

What the generator adds

The sources come from Google's Content Security Policy guide for the Maps JavaScript API. Each directive covers a different part of the map:

DirectiveWhat breaks without it
script-srcThe API script never loads, so there's no map and no Maps error either.
img-srcGrey tiles, missing markers and icons.
connect-srcMap data and service calls such as Places fail.
worker-srcParts of the map that run in a web worker fail.
font-src / style-srcControls and info windows lose their styling.
frame-srcEmbedded google.com/maps/embed iframes don't load.

How merging works

  • Sources you already have are kept, and Maps sources are added to the end of each directive.
  • If your policy relies on default-src and has no img-src, for example, the generator adds img-src starting from your default-src sources. Adding a directive replaces the fallback, so copying it across stops other images on your site from being blocked.
  • Repeated directives are ignored after the first, matching how browsers read a policy.
  • Send the result as one header. Two separate Content-Security-Policy headers are both enforced, so the stricter one still blocks Maps.

Nonce or allowlist?

Google recommends the nonce-based policy. Your server generates a random value for every response and adds it to your script and style tags; with 'strict-dynamic' the trusted loader can then load the rest of the API. If a cache serves the same HTML to every visitor, a per-response nonce isn't possible, and the allowlist policy is the practical option. Google describes it as weaker because it relies on 'unsafe-inline' and broad Google wildcards.

After deploying, reload a page with a map and check the browser console for Refused to load messages. Our guide to Content-Security-Policy and Google Maps explains each source in more detail, and a free scan reports CSP blocks on your live page.