Build a GDPR-style cookie consent banner snippet — pure HTML/CSS/JS, paste and go.
</body><!-- Cookie Consent Banner — generated by Toolsy, no external requests -->
<div id="cc-banner" class="cc-banner cc-bottom" role="dialog" aria-live="polite" aria-label="Cookie consent">
<div class="cc-content">
<p class="cc-message">We use cookies to improve your experience, analyze traffic, and personalize content. Choose which cookies you allow. <a href="/privacy-policy" class="cc-link">Learn more</a></p>
<div id="cc-prefs" class="cc-prefs" hidden>
<label class="cc-row cc-row-locked">
<span>Necessary <em>(always on)</em></span>
<input type="checkbox" data-cc-cat="necessary" checked disabled />
</label>
<label class="cc-row">
<span>Analytics</span>
<input type="checkbox" data-cc-cat="analytics" checked />
</label>
<label class="cc-row">
<span>Marketing</span>
<input type="checkbox" data-cc-cat="marketing" checked />
</label>
</div>
<div class="cc-actions">
<button type="button" id="cc-decline" class="cc-btn cc-btn-ghost">Decline</button>
<button type="button" id="cc-customize" class="cc-btn cc-btn-ghost">Customize</button>
<button type="button" id="cc-accept" class="cc-btn cc-btn-accent">Accept All</button>
</div>
</div>
</div>
<style>
.cc-banner { position: fixed; left: 0; right: 0; z-index: 9999; display: flex; justify-content: center; padding: 16px; font-family: system-ui, -apple-system, sans-serif; }
.cc-bottom { bottom: 0; }
.cc-top { top: 0; }
.cc-content { max-width: 640px; width: 100%; background: #16171d; color: #f4f4f5; border-radius: 12px; padding: 18px 20px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.cc-message { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }
.cc-link { color: #6366f1; text-decoration: underline; }
.cc-prefs { margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; }
.cc-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.cc-row-locked { opacity: .6; }
.cc-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.cc-btn { border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.cc-btn-ghost { background: transparent; color: #f4f4f5; border: 1px solid rgba(255,255,255,.25); }
.cc-btn-accent { background: #6366f1; color: #fff; }
@media (max-width: 480px) { .cc-actions { flex-direction: column-reverse; } .cc-btn { width: 100%; } }
</style>
<script>
(function () {
var STORAGE_KEY = 'cc_consent_v1';
var categories = ["necessary","analytics","marketing"];
var banner = document.getElementById('cc-banner');
var prefs = document.getElementById('cc-prefs');
function readConsent() {
try { return JSON.parse(localStorage.getItem(STORAGE_KEY) || 'null'); } catch (e) { return null; }
}
function applyConsent(consent) {
window.cookieConsent = consent;
document.dispatchEvent(new CustomEvent('cookieConsentChange', { detail: consent }));
if (banner) banner.style.display = 'none';
}
function saveConsent(consent) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(consent));
applyConsent(consent);
}
var existing = readConsent();
if (existing) {
applyConsent(existing);
} else if (banner) {
banner.style.display = 'flex';
}
document.getElementById('cc-accept') && document.getElementById('cc-accept').addEventListener('click', function () {
var consent = {}; categories.forEach(function (c) { consent[c] = true; });
saveConsent(consent);
});
document.getElementById('cc-decline') && document.getElementById('cc-decline').addEventListener('click', function () {
var consent = {}; categories.forEach(function (c) { consent[c] = false; });
consent.necessary = true;
saveConsent(consent);
});
document.getElementById('cc-customize') && document.getElementById('cc-customize').addEventListener('click', function () {
if (prefs) prefs.hidden = !prefs.hidden;
if (prefs && !prefs.hidden) return;
var consent = {};
(prefs ? prefs.querySelectorAll('[data-cc-cat]') : []).forEach(function (input) {
consent[input.getAttribute('data-cc-cat')] = input.checked;
});
if (Object.keys(consent).length) saveConsent(consent);
});
})();
</script>Check window.cookieConsent.analytics / .marketing (or listen for the cookieConsentChange event) before loading analytics or marketing scripts.
Generate a lightweight, dependency-free cookie consent banner — pure HTML, CSS, and vanilla JavaScript, no external scripts or trackers. Choose which cookie categories you use (necessary, analytics, marketing, preferences), banner position, colors, and button text, then copy the ready-to-paste snippet into your site. Consent choices are stored in localStorage and exposed as a `window.cookieConsent` object your analytics/marketing scripts can check before firing.
This tool generates a lightweight, dependency-free cookie consent banner using pure HTML, CSS, and vanilla JavaScript without any external scripts or trackers. Users can customize banner positions, colors, categories, and text, then easily copy and paste the snippet directly into their website. Consent choices are stored locally and exposed via a global object, making it straightforward for custom analytics and marketing scripts to verify user permissions.
Good to know: Sites requiring complex enterprise consent management platforms with automated cookie scanning or advanced regional geo-targeting may need a more robust, specialized solution.
Generate and customize a lightweight, dependency-free cookie consent banner for your website in minutes.
Configure your banner appearance and categories
Select your desired banner position, colors, and button text. Choose which cookie categories your site uses, such as necessary, analytics, marketing, or preferences.
Copy the generated HTML, CSS, and JS
Review the ready-to-paste snippet generated by the tool. Copy the pure, vanilla code directly to your clipboard.
Paste the code into your website
Insert the copied snippet into your website without needing any external scripts or trackers. User consent choices will automatically be stored in localStorage.
Check consent state in your scripts
Use the exposed window.cookieConsent object to check user preferences before firing your analytics or marketing scripts.
Estimated time: PT2M
Share this tool
Build a Privacy Policy & Terms of Service from a quick questionnaire — free, client-side.
Create a mutual or one-way NDA from a quick form — free, client-side, no signup.
Generate a robots.txt file with crawl rules and sitemap.
Generate an RFC 9116 security.txt file for responsible vulnerability disclosure.
Generate SEO-optimized content with AI — blog posts, articles, and more.
Preview how your page looks when shared on social media platforms.
Create an XML sitemap with priority, frequency, and lastmod.
Generate creative domain name ideas from keywords.
Validate sitemap XML structure, detect errors and SEO issues.
Scan sitemap URLs for broken links, redirects, and errors.
Convert text or Markdown to a Word .docx file with live preview, RTL, and page-setup options.
Draw a Secret Santa with exclusions and share a private reveal link for each person.
Make custom bingo cards from your own words — play, print, or share a link.
Convert images to video with the Ken Burns zoom/pan effect. Add music and export as WebM.
Load and compare multiple URLs side by side in resizable iframes.
Rank anything with quick 1-v-1 matchups → a full ordered list you can share.
Convert Markdown to a fully customized, RTL-ready PDF.
See your public IP address plus full location, ISP, ASN, timezone, coordinates, and more.