Cookie Consent Banner Generator
Generate GDPR-compliant cookie consent banners with customizable position, theme, text, and colors.
Position: bottomTheme: darkLines: 26Bytes: 1425
How to implement a GDPR cookie consent banner
Under GDPR, websites must obtain consent before storing non-essential cookies. This banner uses localStorageto remember the user's choice. Add the generated code just before the closing </body> tag. The banner hides automatically once the user accepts or declines.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Adding a consent banner to a site that sets non-essential cookies.
- Producing a self-hosted banner instead of loading a third-party consent platform.
- Getting a starting point you then wire to your actual cookie-setting code.
- Producing markup that does not itself load trackers.
- Building a banner that defaults to rejecting rather than accepting.
Frequently Asked Questions
- Does this banner make my site GDPR compliant?
- No, and no banner alone can. GDPR requires that non-essential scripts do not run *before* consent. This generates the banner and stores the choice in `localStorage` under `cookieConsent`; you still have to gate your analytics and marketing tags on that value.
- How do I actually block the scripts?
- Do not emit them until the flag says accepted: wrap the tag in a check on `localStorage.getItem('cookieConsent') === 'accepted'`, or inject it from your accept handler. Loading Google Analytics and then setting a flag afterwards is the single most common compliance failure.
- Do I need a decline button?
- In the EU and UK, yes — refusing must be as easy as accepting, and France's CNIL has fined sites specifically for a missing or buried reject option. The decline text is optional here only because the same banner is used outside those jurisdictions.
- Why localStorage rather than a cookie?
- It keeps the record on the device without sending anything on every request, and a consent record is itself strictly necessary, so it is permitted before consent. The trade-off: `localStorage` is per-origin, so a consent given on the apex domain does not carry to a subdomain.
- How long should consent last?
- The CNIL recommends re-asking after six months, and the EDPB treats consent as needing renewal rather than being permanent. `localStorage` has no expiry, so store a timestamp alongside the choice and clear it yourself once it ages out.
- Must a banner offer reject as prominently as accept?
- Under GDPR guidance and several national regulators' rulings, yes — consent must be as easy to refuse as to give. A prominent accept button beside a buried link in settings is the pattern enforcement actions have targeted.
Common errors and gotchas
- Showing a banner while setting the cookies anyway, which is the most common compliance failure there is.
- Making reject harder than accept, which regulators have repeatedly ruled invalid.
- Treating generated markup as legal advice, which it is not.
- Blocking the whole page behind the banner, which harms accessibility and usability.
- Loading analytics before consent is given, which the banner then cannot undo.
Related Generators tools
UUID Generator
Generate secure v4 UUIDs.
QR Code Generator
Create customizable QR codes and export as SVG or PNG.
Lorem Ipsum
Generate placeholder paragraphs, sentences, or word lists.
Random Hex Generator
Generate cryptographically random hexadecimal strings.
Random Number String
Generate a random string of digits of any length.
Random String Generator
Generate random strings from a custom character set.
Random Color Generator
Generate random colors as HEX, RGB, and HSL.
MAC Address Generator
Generate random MAC addresses in several formats.