A beautiful, animated birthday countdown timer built with vanilla HTML, CSS, and JavaScript — no frameworks, no dependencies.
- Live Countdown — Shows days, hours, minutes, and seconds ticking in real time
- Custom Date Picker — Set any birthday date using the date input
- Persistent Storage — Your chosen date is saved in
localStorageand survives page refreshes - Progress Bar — Visual progress showing how far through the year you are toward the birthday
- Confetti Burst — Canvas-based confetti launches automatically when the birthday arrives
- Floating Balloons — Animated balloons float up continuously in the background
- Flip Animations — Each number animates smoothly every time it changes
- Birthday Message — A glowing alert appears when the countdown hits zero
- Responsive Design — Works on desktop, tablet, and mobile screens
No installation or build step needed. Just open the file in a browser:
# Clone or download the project, then simply open:
index.html- On page load, the target date is read from
localStorage(falls back to Sep 16 2026) setIntervalruns every 1000ms and calculates the difference between now and the target date- Days, hours, minutes, and seconds are derived using modulo arithmetic
- On each tick, only changed values trigger DOM updates and animations
- Reads the date input value and parses it as a local midnight timestamp (
T00:00:00) - Saves to
localStorageunder the keybday_countdown_target - Resets
prevValuesto-1so all four cards re-render immediately - Clears and restarts the interval to avoid stale closures
- Baseline is set to exactly 1 year before the target date
- Progress =
(now - oneYearAgo) / (target - oneYearAgo) × 100 - Clamped between
0%and100%
- Uses the HTML5
<canvas>API - Spawns colored rectangular pieces from the top of the screen
- Each piece has random velocity, rotation speed, and fade-out
- Auto-stops spawning after 6 seconds; existing pieces fade naturally
In script.js, find this line:
let targetDate = new Date(2026, 8, 16); // Month is 0-indexed: 8 = SeptemberChange the values to (year, monthIndex, day) — note that months are 0-indexed (0 = January, 11 = December).
In style.css, edit the CSS variables at the top:
In index.html:
Someone Special's Big Day
```The event-name paragraph is auto-updated by JS when a date is set. You can change the <h1> freely.
- The countdown uses the local system time of the user's browser — no server sync
- If the target date is in the past, the timer shows
00:00:00:00and fires confetti localStorageis not available in some private/incognito modes on certain browsers
Free to use and modify for personal projects.