Free Cookie Consent Banner Generator
Generate a customizable cookie consent banner with category choices, local preference storage, withdrawal controls and code to gate optional scripts. No subscription or API needed.
Integrate optional scripts before publishing
Paste the generated snippet once per page, before optional integrations. Remove the original executable tags for optional scripts. Change them to inert markup, using one of your enabled categories:
<script type="text/plain" data-fpt-category="analytics" data-src="https://your-analytics-provider.example/script.js"></script> <script type="text/plain" data-fpt-category="analytics"> // Your provider-specific initialization code goes here. </script>
The example URL is a placeholder. Replace it with your real provider URL. Add the external loader before initialization; marked classic scripts run in document order, with each external script’s load event awaited before the next script is inserted. A failed external load stops later scripts in that category and emits fpt:consenterror. Your provider may still require its own ready callback. Module scripts and complex tag managers require custom integration.
Only marked scripts are gated. The code does not intercept normal script tags, tracking pixels, iframe embeds, plugins, server requests or cookies set elsewhere. Keep those disabled until the relevant category is granted. A Content Security Policy may require nonces or separate approved script/style files; adapt the snippet to your policy.
Read choices and react to changes
window.FPTConsent.getConsent(); // necessary, enabled categories, decided
window.FPTConsent.open(); // reopen category settings
window.FPTConsent.withdraw(); // reject optional categories
document.addEventListener("fpt:consentchange", function (event) {
const choices = event.detail;
// Start/stop your own integrations according to these choices.
});The API is available after the snippet runs. Marked scripts added later are also observed. Choices are shared across tabs on the same origin. A change of version, category list or an expired choice disables optional scripts on the next load. Revoking a granted category reloads the page; arrange form-save flows accordingly.
Check your actual integration
In a clean browser profile, inspect requests and storage before making a choice. Reject optional categories and confirm that their resources remain blocked. Enable each category separately, reload to check persistence, then withdraw and confirm the resources stay blocked after the reload. Review retention, disclosure and deletion behavior for each provider.
Consent must reflect the actual deployment. For current UK guidance on consent controls, withdrawal and retention, consult the ICO’s practical consent guidance. Other jurisdictions and technologies may require different handling.
How to use cookie consent banner generator
Enter your site name and actual cookie or privacy policy URL. Select optional categories used by your site and review the wording.
Generate the HTML and test accept, reject, customize and withdrawal in the isolated preview.
Install the snippet once on every page before optional integrations. Convert optional scripts to the inert markup below and connect other integrations to the consent API.
Test the deployed site’s requests and storage before consent, after reject, after accepting individual categories and after withdrawal.
Privacy and scope
Configuration stays in this page until you reset or leave. Code generation and preview use no API. The preview is sandboxed and blocks network resources; it cannot change this site’s consent. The code you install uses your own website’s localStorage for visitor choices.
The tool does not save inputs in browser storage. Reset or leave the page to clear its in-page state. Downloads and clipboard copies remain wherever you save or paste them.
Frequently asked questions
Does this automatically block every tracker on my site?
No. Only scripts you change to type="text/plain" with a supported data-fpt-category are activated after permission. Remove their original script tags and prevent tag managers, embeds, plugins, tracking pixels and server-side integrations from loading them separately. Integrations outside the generated gate need their own consent handling. Test your actual site before publishing.
What does the generated code do?
It shows equally styled accept and reject buttons, category choices that start disabled, a policy link and a permanent settings button. It remembers a choice locally with your version and retention period. It gates marked scripts, publishes a consent-change event, and reloads when a previously granted category is revoked so gated scripts do not restart with that choice.
Is the generated banner a compliance guarantee?
No. Applicable requirements depend on your jurisdiction, purposes, technologies and actual implementation. This is a technical starting point, not a consent management platform certification or legal assessment. You must accurately describe technologies and recipients, configure every integration and verify that withdrawal works.
Where are choices stored?
The installed banner uses localStorage on your own website, under fpt-cookie-consent. Records include categories, a version, choices, and timestamps; no server consent log is provided. If storage is unavailable, choices work for the current page only. The isolated preview cannot use the main website’s storage. Changing the version or optional categories invalidates old choices.
Does withdrawal remove every cookie?
No. The code disables future marked-script activation and reloads when permission is reduced. It cannot delete third-party or HttpOnly cookies or undo data already sent. Your integrations must stop processing and handle applicable cookie deletion or opt-out requirements. The generated event and API let you connect those integration-specific controls.
How long should a choice be remembered?
The selected period is a technical setting, not a universal legal deadline. Choose a period appropriate to your purposes and applicable guidance. The default is 180 days and can be changed from 1 to 365 days. A change of purposes should use a new version and obtain an appropriate new choice.