Advanced

Cookie Consent Banner Generator

Build a cookie banner that meets UK rules: Accept and Reject buttons side by side, per-category choices, scripts held back until people agree, and a link to change their mind. HTML, CSS and JavaScript, ready to paste in.

Wording
Categories
Look and behaviour

Live preview

The preview runs the real code in a sandbox, so its choice isn’t remembered between previews.

Code to paste in


    
Advertisement

About this tool

Under the UK’s PECR rules, you need consent before setting cookies or similar tracking that isn’t strictly necessary, and the ICO expects rejecting to be as easy as accepting: no pre-ticked boxes, no “by continuing you agree”, and a Reject button as prominent as Accept. This banner does that, and holds back any script you mark with a category until the visitor agrees. Change <script src="…"> to <script type="text/plain" data-cookie-category="analytics" src="…"> and it only runs after consent, including on later visits.

Since 5 February 2026, the Data (Use and Access) Act lets first-party analytics, used only to improve your own site, run without consent if you explain it and offer a simple way to opt out; choose that option to have them on by default with an opt-out in the settings. Advertising, cross-site tracking and social media pixels still need consent. The choice is stored for 6 or 12 months, the data-cookie-settings link lets people change their mind at any time, and Google Consent Mode v2 signals can be sent for Google tags. The code has no outside dependencies. Your settings are remembered on this device.