Developer Utilities · Free tool
Cookie Consent Generator
Drop-in HTML+JS cookie consent banner with localStorage persistence and customizable colors and position.
Updated May 2026
<div id="cookie-banner" style="display:none;position:fixed;bottom:0;left:0;right:0;padding:1rem;background:#0f172a;color:#ffffff;font-family:system-ui,sans-serif;z-index:9999;box-shadow:0 -4px 12px rgba(0,0,0,0.15)">
<p style="margin:0 0 0.75rem 0;font-size:0.875rem;line-height:1.5">
We use cookies to improve your experience. <a href="/privacy" style="color:#0f766e;text-decoration:underline">Privacy Policy</a>
</p>
<div style="display:flex;gap:0.5rem;flex-wrap:wrap">
<button onclick="cookieAccept()" style="background:#0f766e;color:#fff;border:0;padding:0.5rem 1rem;border-radius:0.375rem;font-weight:600;cursor:pointer">Accept</button>
<button onclick="cookieReject()" style="background:transparent;color:#ffffff;border:1px solid #ffffff;padding:0.5rem 1rem;border-radius:0.375rem;font-weight:600;cursor:pointer">Reject</button>
</div>
</div>
<script>
(function() {
var KEY = "cookie-consent";
var banner = document.getElementById("cookie-banner");
if (!localStorage.getItem(KEY)) banner.style.display = "block";
window.cookieAccept = function() {
localStorage.setItem(KEY, "accepted");
banner.style.display = "none";
// Add analytics/tracking initialization here
};
window.cookieReject = function() {
localStorage.setItem(KEY, "rejected");
banner.style.display = "none";
};
})();
</script>For GDPR compliance you also need to: (1) not load tracking scripts until consent is given, (2) provide a way to withdraw consent later, (3) track consent for at least 6 months. This banner stub handles UI; you must wire it to your analytics initialization.
Found this useful?Email
Advertisement
What it does
Drop-in HTML+JS cookie consent banner. Accept/Reject buttons (recommended for GDPR), localStorage persistence, configurable position and color. Banner stub only — wire to your analytics initialization manually.
Embed this tool on your siteShow snippetHide
Paste this snippet into any page. Loads on-demand (lazy), no tracking scripts, and sized to most dashboards. Replace the height to fit your layout.
<iframe src="https://freetoolarena.com/embed/cookie-consent-generator" width="100%" height="720" frameborder="0" loading="lazy" title="Cookie Consent Generator" style="border:1px solid #e2e8f0;border-radius:12px;max-width:720px;"></iframe>How to use it
- Customize colors, position, button labels.
- Set the URL of your privacy policy.
- Copy the generated HTML+script.
- Paste before </body> in your site template.
Frequently asked questions
- Is this GDPR-compliant?
- It handles UI and consent persistence. For full GDPR you also need to (1) NOT load tracking scripts until consent is given, (2) provide a way to withdraw consent, (3) document consent for at least 6 months. The accept/reject handlers are stubs — you wire your own logic.
Advertisement
Learn more
Guides about this topic
- Using Our Tools · GuideHow to generate QR codesMake a QR code for a URL, wifi, vCard, or plain text. What error-correction means, how big to print, how to test it.
- Using Our Tools · GuideHow to create a strong passwordThe entropy math, 2026 NIST rules, passphrases vs passwords, password managers, MFA and hardware keys, where passkeys fit, 5 mistakes that still lose accounts
- Developers & Technical · GuideHow to encode and decode Base64What Base64 is (not encryption), the 3-to-4 encoding mechanics, standard vs URL-safe vs MIME variants, 33% overhead, when to use it, common mistakes
- Design & Media · GuideHow to choose a color paletteHSL color theory, four palette schemes (monochromatic, analogous, complementary, triadic), the 60-30-10 rule, WCAG contrast, dark mode, and palette tools.
- Developers & Technical · GuideHow to use JWT tokens securelyJWT anatomy, HS256 vs RS256, the 'alg: none' attack, expiration strategy, storage (localStorage vs httpOnly cookies), revocation patterns, and claim validation.
- Design & Media · GuideHow to design a faviconThe sizes you actually need in 2026, design principles that survive 16×16 rendering, dark mode support, the HTML tags, web manifest, and testing.
Explore more developer utilities tools
- .htaccess GeneratorGenerate Apache .htaccess with HTTPS redirect, Gzip, caching, error pages, hotlink protection, 301 redirects.
- Color Palette ExtractorExtract dominant colors from any image. Histogram-based, runs in browser. Click swatches to copy hex.
- XML Sitemap GeneratorGenerate sitemap.xml from a URL list. Sets lastmod to today, applies priority and changefreq. Download or copy.
- JavaScript MinifierStrips comments and collapses whitespace from JS. For production minification, use terser or esbuild.
- HTML Table GeneratorInteractive HTML table builder. Click cells to edit. Toggle headers, stripes, borders. Inline-styled output for emails.
- CSS Button GeneratorVisual CSS button generator. Hover, active, and focus-visible states baked in. Tunable colors and sizing.