Skip to content
Free Tool Arena

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 snippet

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>
Embed docs →

How to use it

  1. Customize colors, position, button labels.
  2. Set the URL of your privacy policy.
  3. Copy the generated HTML+script.
  4. 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

Explore more developer utilities tools

100% in-browserNo downloadsNo sign-upMalware-freeHow we keep this safe →