How to add a countdown timer to Shopify without an app
A countdown is one of the easiest things to build into your theme yourself. Here is a complete section, how to install it, and how to use it without annoying your customers.
Key takeaways
- A countdown timer is presentation, not data, so a theme section does the job with no app and no monthly fee.
- Shopify has no date-and-time setting for sections, so the end time is a text setting in a fixed format that the script reads.
- The timer should hide itself (or show a message) when it reaches zero, so an old sale never shows a broken clock.
- Only count down to a real deadline. A timer that resets for every visitor is a fake urgency claim, and consumer law in the EU and UK treats it that way.
Countdown timers are one of the most installed kinds of Shopify app, and most of them do one thing: show the time left until a date. That does not need a server, a database or an app subscription. It needs a few lines of Liquid for the layout, a schema so you can set the date in the theme editor, and a small script that updates the numbers every second. Below is a complete section that does exactly that.
Do you need an app for a countdown timer?
Not for the usual case: one sale, one end date, shown on the homepage, a collection or a product page. An app earns its place when the timer has to be per customer (an offer that starts when each visitor arrives and is enforced at checkout), when it must change prices automatically when it ends, or when you need reports on it. Those need a backend. A plain sale countdown does not, and a section has two advantages: it loads nothing on pages where you have not added it, and it keeps working whatever happens to an app's pricing. Our comparison of Shopify apps and custom sections covers the trade-off in general.
The countdown timer section
This is the whole section. It shows a heading, the days, hours, minutes and seconds left, and an optional button. Every word is a setting, the colours follow your theme's colour schemes, and when the time runs out it either hides or shows your "sale has ended" message.
{%- liquid
assign end = section.settings.end_time | strip
-%}
<div
class="color-{{ section.settings.color_scheme }} cdt"
id="cdt-{{ section.id }}"
data-end="{{ end }}"
data-ended="{{ section.settings.when_ended }}"
{{ section.shopify_attributes }}
>
<div class="page-width cdt__inner">
{%- if section.settings.heading != blank -%}
<h2 class="cdt__heading">{{ section.settings.heading }}</h2>
{%- endif -%}
<div class="cdt__clock" role="timer" aria-live="off">
<span><b data-unit="d">0</b>{{ section.settings.label_days }}</span>
<span><b data-unit="h">00</b>{{ section.settings.label_hours }}</span>
<span><b data-unit="m">00</b>{{ section.settings.label_minutes }}</span>
<span><b data-unit="s">00</b>{{ section.settings.label_seconds }}</span>
</div>
<p class="cdt__ended" hidden>{{ section.settings.ended_text }}</p>
{%- if section.settings.button_label != blank -%}
<a class="button" href="{{ section.settings.button_link }}">{{ section.settings.button_label }}</a>
{%- endif -%}
</div>
</div>
<style>
#cdt-{{ section.id }} .cdt__inner { padding: 40px 0; text-align: center; display: grid; gap: 20px; justify-items: center; }
#cdt-{{ section.id }} .cdt__clock { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
#cdt-{{ section.id }} .cdt__clock span { display: grid; min-width: 72px; padding: 12px 8px; border: 1px solid rgba(var(--color-foreground), .15); border-radius: 12px; font-size: 13px; }
#cdt-{{ section.id }} .cdt__clock b { font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; }
</style>
<script>
(function () {
var root = document.getElementById('cdt-{{ section.id }}');
if (!root || root.dataset.ready) return;
root.dataset.ready = '1';
// "2026-12-24 23:59" is read in the visitor's time zone; add "Z" or "+01:00" to pin it to one zone.
var end = new Date(root.dataset.end.replace(' ', 'T')).getTime();
if (isNaN(end)) return;
var pad = function (n) { return n < 10 ? '0' + n : '' + n; };
var timer;
function tick() {
var left = Math.max(0, end - Date.now());
var s = Math.floor(left / 1000);
root.querySelector('[data-unit="d"]').textContent = Math.floor(s / 86400);
root.querySelector('[data-unit="h"]').textContent = pad(Math.floor(s / 3600) % 24);
root.querySelector('[data-unit="m"]').textContent = pad(Math.floor(s / 60) % 60);
root.querySelector('[data-unit="s"]').textContent = pad(s % 60);
if (left === 0) {
clearInterval(timer);
if (root.dataset.ended === 'hide') { root.hidden = true; }
else { root.querySelector('.cdt__clock').hidden = true; root.querySelector('.cdt__ended').hidden = false; }
}
}
tick();
timer = setInterval(tick, 1000);
})();
</script>
{% schema %}
{
"name": "Countdown timer",
"tag": "section",
"settings": [
{ "type": "text", "id": "heading", "label": "Heading", "default": "Winter sale ends in" },
{ "type": "text", "id": "end_time", "label": "Ends at", "default": "2026-12-24 23:59", "info": "Format: YYYY-MM-DD HH:MM, in the visitor's time zone. Add +01:00 (your offset) to fix it to yours." },
{ "type": "select", "id": "when_ended", "label": "When the time is up", "default": "message",
"options": [ { "value": "message", "label": "Show the message" }, { "value": "hide", "label": "Hide the section" } ] },
{ "type": "text", "id": "ended_text", "label": "Message", "default": "The sale has ended. Thank you!" },
{ "type": "text", "id": "label_days", "label": "Days label", "default": "days" },
{ "type": "text", "id": "label_hours", "label": "Hours label", "default": "hours" },
{ "type": "text", "id": "label_minutes", "label": "Minutes label", "default": "min" },
{ "type": "text", "id": "label_seconds", "label": "Seconds label", "default": "sec" },
{ "type": "text", "id": "button_label", "label": "Button label", "default": "Shop the sale" },
{ "type": "url", "id": "button_link", "label": "Button link" },
{ "type": "color_scheme", "id": "color_scheme", "label": "Colour scheme", "default": "scheme-1" }
],
"presets": [ { "name": "Countdown timer" } ]
}
{% endschema %}The colour setting uses color_scheme, which Dawn and most Online Store 2.0 themes from 2023 on support. If your theme is older and the editor shows an error for it, delete that setting and the color-{{ section.settings.color_scheme }} class, and the section takes the page's colours.
How to install it
Duplicate your theme
In Shopify, go to Online Store › Themes, open the ⋯ menu on your live theme and choose Duplicate. Work on the copy so nothing changes for customers until you publish.
Add a new section file
On the copy, choose ⋯ › Edit code. Under Sections, click Add a new section, name it
countdown-timerand create it.Paste the code
Replace everything in the new file with the code above and press Save. If Shopify shows a schema error, check that the whole
{% schema %}block was copied.Add it to a page
Open Customize, choose Add section where you want the timer and pick Countdown timer.
Set the end time and words
Type the end in the format shown, for example
2026-12-24 23:59+01:00, then change the heading, labels and button. Preview it, then publish the theme.
If the section does not appear under Add section, the usual cause is a missing or broken presets entry. Our guide to a custom section not showing in the theme editor goes through every cause.
Getting the time zone right
A date like 2026-12-24 23:59 with nothing after it is read in each visitor's own time zone, so a shopper in New York and one in Madrid see different amounts of time left. That is fine for "ends at midnight, wherever you are". If the sale ends at one moment for everybody, add your offset, such as +01:00 for Madrid in winter, or Z for UTC. Remember that the offset changes with daylight saving time, so check it against the date of the deadline, not today's.
Use a countdown honestly
A countdown works because it is true: the price really goes back up, or the drop really closes. Timers that restart for every visitor, or that roll over to a new deadline the moment they hit zero, are a known dark pattern. Under EU and UK consumer law a false claim that an offer is only available for a very limited time is an unfair commercial practice, and shoppers who see the same "ends in 10 minutes" twice stop believing everything else on the page.
- Set the timer to the real end of the offer, and end the offer then.
- Choose Hide the section for flash sales, so a finished sale disappears on its own.
- Put one timer on a page. Several timers counting to the same moment add noise, not urgency.
- Pair it with the offer itself: what is discounted, by how much, and a button to it.
Ready-made countdown sections
If you would rather start from something designed, the marketplace has countdown sections built the same way, as plain theme sections with no app. Pulse Countdown CTA sets the time left very large beside a photograph, and Split-Flap Drop is a launch countdown on a 3D split-flap board that also takes sign-ups. You can browse every Shopify call-to-action section there, or describe the exact timer you want to the Shopify Liquid code generator and get the section written for your store.
Questions, answered
Can I add a countdown timer to Shopify for free?
Yes. A countdown is a theme section: paste the code from this guide into a new section file and add it in the theme editor. There is no app and no monthly fee.
Will a countdown timer section slow down my store?
No more than a few lines of HTML and a small script. It loads only on pages where you add it, and it updates four numbers once a second.
Can I put the countdown timer on product pages?
Yes. Open a product template in the theme editor and add the section there, above or below the product information. Products with different deadlines can use their own templates.
What happens when the countdown reaches zero?
With the code in this guide you choose: the section hides itself, or the clock is replaced by your message, such as "The sale has ended". It never shows negative or frozen numbers.
Does the timer end the discount too?
No. The section only shows the time. End or schedule the discount itself in Shopify under Discounts, with the same end date, so the two always agree.