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.
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:
| Directive | What breaks without it |
|---|---|
| script-src | The API script never loads, so there's no map and no Maps error either. |
| img-src | Grey tiles, missing markers and icons. |
| connect-src | Map data and service calls such as Places fail. |
| worker-src | Parts of the map that run in a web worker fail. |
| font-src / style-src | Controls and info windows lose their styling. |
| frame-src | Embedded 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.