Free popup HTML code generator
What this does. It writes a small, zero-dependency script that opens a centred popup after a delay you choose, with a headline, a short paragraph, a button that links where you point it, a close button and a cooldown so the same browser is not interrupted again straight away.
What it does not do. It does not collect email addresses, validate a form, target particular pages, send analytics or run A/B tests. The button is a link, not a form. Treat the output as a starting point you test on your own site, not a finished campaign.
A popup is a few dozen lines of JavaScript: wait, build a dialog, let the visitor close it, remember that they did. This page writes those lines for you so you can paste them into a static site, a theme footer or a custom-code area without installing anything.
The generated code builds the dialog from DOM nodes and sets your text with textContent, so an apostrophe or angle bracket in your headline cannot break the markup. The button link only accepts web links, mail links and same-site paths.
Build your snippet
Preview
The preview shows the dialog's look. The delay, close button and cooldown work in the generated code on your own page.
Generated snippet
Paste it before the closing </body> tag, or into your platform's footer or custom-code area. Nothing is sent anywhere: the code only runs in the visitor's browser.
How the snippet works
- It checks the cooldown. A timestamp in localStorage stops the same browser from seeing the popup again inside the window. If storage is blocked, it simply shows the popup.
- It waits for the delay. A single timer starts when the script runs.
- It builds the dialog. Nodes are created in script, with the role and label a screen reader needs, and your copy is inserted with
textContent. - It closes three ways. The close button, a click on the dark backdrop or the Escape key. Focus moves to the close button when it opens.
What to test before you ship
- The delay. Load the page and wait. Nothing should appear before the delay passes.
- All three close routes. Button, backdrop and Escape.
- The cooldown. Close it, reload, and confirm it stays away. Clear site data to reset while testing.
- Mobile width. The dialog should fit a narrow screen without the button falling off it. Test a real phone, not only a resized window.
- The link. Click the button and confirm it goes where you meant.
- Your own pages. Keep it off checkout, sign-in and payment pages.
Limits worth knowing
A popup that covers the page right after load is the pattern search engines and visitors both dislike most on phones. Google's guidance on intrusive interstitials is about exactly this, so on small screens prefer a bar or a slide-in over a full-screen dialog, and give the visitor a reason to see it first.
The snippet has no analytics, no email field and no page rules. If your site uses a strict Content-Security-Policy, an inline script needs a nonce or hash, or you can save the code as a file your site already serves.
Prefer a hosted popup instead of maintaining custom JavaScript? Open a matching template in the studio. It adds URL targeting, frequency rules, an email field and a lead inbox, and it installs with two lines of code on any site that allows a script. The no-limits page explains what the hosted version does and does not include.
Common questions
Is the generated popup code free to use?
Yes. The code is yours to use and change, with no attribution required. It is provided as-is without warranty, so test it on your own site first.
Does it collect email addresses?
No. The button is a link. To collect emails you need a form and somewhere to send the responses, which is what a hosted popup builder with a lead inbox does.
Where do I paste the code?
Before the closing body tag of your page, or in your platform's footer or custom-code area. On WordPress that usually means a code-snippet plugin or a child theme; on Shopify, theme code outside checkout; on Webflow, a custom code embed.
Why does it not show up on my site?
Check that the delay has passed, that you have not already seen it inside the cooldown (clear site data to test again), that the code is pasted on the page you are viewing, and that a Content-Security-Policy is not blocking the inline script.
Will this hurt my search ranking?
It can if it covers the main content straight away on a phone. Keep the delay, show it rarely, make it easy to close, and prefer a smaller format on small screens. The generator makes no ranking claim.
Related tools and pages
- Announcement bar generator — a sticky top or bottom bar with a dismiss button.
- Exit-intent code generator — a desktop-only trigger with sensitivity, delay and cooldown.
- Popup copy generator — headline and button combinations for four common goals.
- Static HTML popup guide — where the two lines go on a hand-built site.
- Popup not showing? — a checklist for the usual causes.
Method and limitations
The generator runs entirely in your browser. It writes code from your inputs and does not send them anywhere. The snippet is provided as-is, without warranty, and was previewed in this page but not tested on every browser, theme or platform. No conversion rate, traffic or revenue claim is made.
Written by Shailu016, founder of PopupLoom. Last updated 20 November 2026. Corrections: support@popuploom.com.