Cookie Consent Generator

Use this cookie consent generator to build a banner for your website without a plugin or a paid service. Write the message, style it to match your site, preview it live, and copy one self-contained snippet of code.

1Write your banner message
2Style colours and position
3Copy and paste the code

The generated snippet is shown as text only — it is never executed on this page. On your own site it runs as ordinary HTML, CSS and JavaScript with no external dependencies.

Private by design: 100% in your browser — nothing is uploaded, no sign-up. This tool runs entirely on your device.

Cookie banners are the small bars and cards that appear at the edge of a website asking about cookies. They exist because privacy law in much of the world treats analytics and advertising cookies as optional extras: a site may only set them after the visitor agrees. Hiring a consent platform for a small website can cost more than the hosting, yet the banner itself is simple technology — a message, two buttons and a memory of the answer. This generator writes that code for you, styled your way, in one copy-and-paste block.

How the snippet behaves is deliberately boring, which is what you want from consent code. On a first visit it checks the browser's local storage for a saved choice. Finding none, it shows the banner. When the visitor clicks Accept or Decline, the choice is saved and the banner disappears — on that page, on every other page, and on future visits, until the visitor clears their browser storage. There are no external requests, no libraries and nothing to phone home to, so the banner cannot slow your site down or leak your visitors' behaviour to a third party.

Worked example: a recipe blog wants a discreet banner that matches its dark footer. The owner writes "We use cookies to improve your experience and to analyse traffic. By clicking Accept, you agree to our use of cookies.", keeps the labels Accept and Decline, picks a charcoal background with white text and a blue button, and chooses the bottom-right card position so the banner never covers the recipe. The preview shows exactly that card. One click copies the code, and it goes into the blog's footer template just before the closing body tag — after which every page on the site shows the banner to new visitors and remembers their answer.

Choosing a banner style that fits your site

PositionBest for
Bottom barMost sites — visible, standard, easy to find later
Top barSites with busy footers or fixed bottom navigation
Card, bottom rightBlogs and portfolios — discreet and modern
Card, bottom leftSites whose chat widget already sits bottom right

Write the message like a person, not a lawyer. Say what cookies are for in one or two short sentences, and if you want, add "Read our privacy policy for details" with a link — you can paste the link into the message area of the code after copying. Keep both buttons equally easy to click: hiding the Decline option or making it hard to find is against the spirit of consent law in several regions and erodes visitor trust everywhere. Equal buttons, honest words, remembered choice — that is the whole recipe.

One honest limitation: this basic banner records consent; it does not by itself stop other scripts from setting cookies first. If your site runs advertising or analytics and you operate under strict rules such as the GDPR, the recommended pattern is to load those scripts only after an "accepted" choice is saved. The generated code keeps the choice in a clearly named local storage key, so a developer can wire that condition in minutes — and the preview and generator remain the quickest way to get the visible banner exactly right.

A detail many site owners miss: consent is not forever, and it is not transferable. If you later add a new category of cookie — say you start running adverts on a site that previously only used analytics — the old "accepted" no longer covers it, and visitors should be asked again. A simple way to handle this with the generated snippet is to change the storage key name (for example from cookie-consent-choice to cookie-consent-choice-2) whenever your cookie use changes materially. Every visitor then sees the banner once more, makes a fresh choice, and your consent stays honest.

Frequently asked questions

Does my website need a cookie consent banner?

If your site sets non-essential cookies — analytics, advertising, embedded videos or social widgets — then laws in the EU, UK and elsewhere require you to ask for consent before setting them. A banner is the usual way to ask.

How does the generated banner work?

The snippet shows the banner only to visitors who have not chosen yet. When someone clicks Accept or Decline, the choice is stored in the browser's local storage and the banner stays hidden on future visits.

Where do I paste the code?

Just before the closing body tag of your pages, or in your theme's footer file if you use a CMS. Paste it once in a shared template or footer so it appears on every page.

Does this banner block cookies before consent?

The basic snippet records the visitor's choice and hides itself. Strict rules in some regions also require that non-essential scripts do not load until consent is given — you can extend the snippet to load your analytics or ad code only after an 'accepted' choice.

Can I change the colours and position?

Yes. The form sets the background, text and button colours and offers four positions: a full-width bar at the bottom or top of the page, or a floating card in either bottom corner. The code updates as you type.

Is a cookie banner the same as a privacy policy?

No. The banner asks for permission; the privacy policy explains in detail what data you collect and why. You need both, and the banner message can link to your policy page.

Will the banner remember returning visitors?

Yes. The choice is kept in local storage, so returning visitors are not asked again on every page. If they clear their browser storage, the banner will politely reappear.

Is this generator free and private?

Yes. The code is generated in your browser; nothing you type is uploaded. The snippet itself is plain HTML, CSS and JavaScript with no external libraries and no tracking.

Does using this banner make my site legally compliant?

A banner is one part of compliance. Your obligations depend on your country, your cookies and how you handle data, so treat this as a solid starting point and get advice for your exact situation if the stakes are high.

Related tools