A countdown timer shows up across a genuinely wide range of motion graphics work, event promos building anticipation, limited time offer graphics, live broadcast style overlays, and product launch teasers. Building one with manually placed keyframes for every single number is technically possible but genuinely tedious, and it makes even a small change to your timer's duration a considerable amount of rework. A single expression solves this far more elegantly, and understanding the underlying logic lets you build a timer that is genuinely easy to customize afterward.
A dynamic countdown timer in After Effects is built by attaching an expression to a text layer's Source Text property, using a Slider Control to set your total duration and the built in time variable to calculate exactly what number should display at any given frame. This post covers the full setup process, formatting your countdown into proper minutes and seconds, adding a count up versus count down toggle, syncing a progress bar or color change to your countdown's final moments, and building a looping timer for repeating content. It also includes a real video walkthrough, frequently asked questions, and links to Freevisuals resources worth pairing with this technique.
By Jack Wright, Founder, Freevisuals. Updated 2026.
Before writing any expression code, create a new text layer through Layer, then New, then Text, and add a Slider Control effect to it through Effect, then Expression Controls, then Slider Control. This slider becomes your timer's adjustable duration, letting you change your countdown's total length later by simply dragging one value rather than rewriting your expression from scratch. Setting this slider to your desired countdown length in seconds, twenty for a twenty second countdown, for instance, gives your upcoming expression a clear, adjustable value to reference.
With your text layer selected, holding Alt on Windows or Option on Mac while clicking the stopwatch icon next to Source Text opens the expression editor directly on that property, ready for you to type or paste your actual countdown logic.
At its simplest, a countdown expression subtracts your composition's current time from your slider's total duration value, then rounds the result to a clean whole number using Math.ceil, which rounds up rather than down, avoiding an awkward moment where your timer briefly shows the wrong number right at the boundary between two seconds. A basic working version reads roughly as Math.ceil(effect("Slider Control")("Slider") minus time), referencing your slider's current value and subtracting the built in time variable representing your composition's current playback position in seconds.
This single line already produces a functional countdown, but pairing it with a Time Remap or checking your composition's actual frame rate against your intended pacing is worth doing early, since a countdown that skips or stutters between numbers usually traces back to a frame rate mismatch between your composition settings and your original creative intent rather than an error in the expression itself.
For a full demonstration building a countdown timer from a completely blank composition through to a finished, customizable result, watch Dynamic Timer, Countdown In After Effects With Expression, Step By Step, which covers exactly this kind of practical build for event broadcasts, fitness videos, and presentation content. This is worth watching specifically because typing expression code correctly the first time, matching quotation marks and parentheses exactly, is often easier to get right after watching someone type it out character by character than by copying a block of code without seeing how each individual piece gets entered.
For countdowns longer than a minute, displaying a raw number of total seconds reads poorly compared to a properly formatted minutes and seconds display. This requires a slightly more involved expression, calculating your minutes value by dividing your remaining seconds by sixty and rounding down, then calculating your remaining seconds value separately, and combining both into a single readable string. A commonly used helper function checks whether a given number is below ten and adds a leading zero if so, ensuring your display reads as a clean 04:07 rather than an inconsistent 4:7 that looks noticeably less polished.
Building this formatting logic as a small reusable function within your expression, rather than repeating the same zero padding check twice for both minutes and seconds separately, keeps your code considerably cleaner and easier to adjust later if you need to extend your timer to include hours for a longer countdown as well.
For templates intended to serve both count up and count down purposes without needing two entirely separate expressions, adding a Checkbox Control effect alongside your slider, then referencing that checkbox's value within your expression, lets a single timer switch behavior based on a simple toggle. Since a checkbox control returns its value as a string type by default, wrapping the reference in a Number conversion is necessary before using it directly in a numeric comparison or calculation, a small but easy to overlook technical detail that causes a checkbox based toggle to behave unexpectedly if skipped.
With this toggle in place, a simple conditional statement checks whether the countdown checkbox is active, and calculates your displayed value accordingly, either counting down from your slider's total toward zero, or counting up from zero toward that same total, giving you one flexible timer template rather than needing to maintain two separate versions for each specific direction.
A countdown timer often reads more clearly alongside a visual progress indicator, a bar or ring that fills or empties in step with your numeric display. Applying an expression to a shape layer's scale property, calculating progress as your remaining time divided by your total duration and clamping the result between zero and one using Math.max, keeps a progress bar's fill level precisely synchronized with your countdown's actual numeric value rather than requiring separately, manually keyframed animation that could drift out of sync if your countdown's duration is later adjusted.
This same synchronized approach extends naturally to a circular progress ring built from a shape layer's Trim Paths End property, referencing the identical underlying progress calculation to animate a stroke that empties or fills in a full circle as your countdown proceeds, a common visual style for event countdowns and loading style graphics alike.
A genuinely effective way to add visual urgency as a countdown approaches zero involves conditionally changing your text's color during its final few seconds. A simple conditional expression checking whether your remaining time has dropped below a specific threshold, three seconds for instance, and switching your text's fill color to red during that final window while keeping it at its normal color otherwise, reinforces the countdown's building tension visually alongside the numeric display itself. This same conditional logic pattern extends to other final moment effects as well, a scale pulse, an added glow, or a fade out precisely timed to your countdown's actual final second rather than a separately, manually keyframed approximation.
For content where a countdown needs to repeat continuously rather than running once and stopping, a modulus operation applied to your time variable resets your countdown automatically once it reaches zero, restarting from your full duration again without needing separate keyframes or a manually looped composition. This works by taking the remainder of your current time divided by your total duration, effectively wrapping your countdown back to its starting value every time it would otherwise reach zero, useful for background graphics or looping social content where a continuously repeating countdown effect is the actual creative intent rather than a genuine, one time event countdown.
Editors working with countdown expressions built in older After Effects versions, or copied from an older tutorial, occasionally run into compatibility errors once opened in a genuinely current version, since After Effects has periodically updated its underlying expression engine. If a working expression from an older source suddenly throws an error after opening in a current version, running the Update Legacy Expressions script, found through File, then Scripts, applies automatically across all compositions in your project, resolves the large majority of these compatibility issues without requiring you to manually rewrite the underlying countdown logic from scratch.
This is particularly worth knowing for anyone building a countdown template intended to remain usable across several years and multiple future After Effects versions, since expression syntax that works perfectly today may eventually need this kind of update pass applied once Adobe releases a future version with underlying engine changes, a normal, expected part of maintaining any expression driven template over a genuinely long working lifespan.
A frequent mistake involves forgetting to convert a checkbox control's string value to a number before using it in a numeric comparison, producing an expression error or unexpected behavior that traces back to this specific type mismatch rather than a genuine logic error elsewhere in the code. Another common issue involves using Math.floor instead of Math.ceil for the core countdown calculation, producing a display that briefly shows the wrong number at the exact boundary between seconds due to how each specific function rounds differently at that transition point.
Skipping the zero padding function for single digit minutes or seconds values is another easy to overlook detail, producing a technically correct but visually inconsistent display that reads noticeably less polished than a properly formatted result with consistent two digit values throughout.
Once your countdown expression is working correctly with all the customization options you actually need, exposing your Slider Control, Checkbox Control, and any other adjustable parameters through the Essential Graphics panel lets you save the entire setup as a Motion Graphics Template, ready to reuse across future projects or hand off to a collaborator without requiring them to understand or edit the underlying expression code directly. This is done by dragging your relevant controls into the Essential Graphics panel and renaming each one clearly, then using the Export As Motion Graphics Template option to produce a genuinely portable, reusable asset.
Building this kind of reusable template pays off considerably for anyone who finds themselves building similar countdown graphics repeatedly across different projects, turning what would otherwise be a rebuild from scratch every time into a matter of dropping in an already proven template and adjusting a handful of exposed slider and checkbox values to fit each new project's specific needs.
A well built countdown pairs naturally with the animation techniques covered in our Easy Ease tutorial, since eased entrance and exit animation on surrounding graphic elements gives a countdown genuine visual polish beyond the numeric expression alone. Our After Effects templates library is also worth browsing for event and promo templates well suited to pairing with this exact technique. For premium templates and additional motion graphics assets, Motion Array and Envato are both worth exploring, and for a ticking clock or buzzer sound effect to pair with your finished countdown, our free sound effects library is worth checking, alongside Artlist and Epidemic Sound for a suspenseful music bed to accompany it.
This usually means Math.floor is being used instead of Math.ceil in your core expression, causing the displayed number to round down slightly early at the boundary between each second. Switching to Math.ceil resolves this timing mismatch.
Yes, since your expression references a Slider Control rather than a fixed hardcoded number, adjusting that slider's value instantly updates your countdown's total duration without requiring any changes to the underlying expression code itself.
Checkbox controls return their value as a string by default, and using that value directly in a numeric comparison without converting it to a number first commonly causes unexpected behavior. Wrapping the reference in a Number conversion resolves this.
Use a modulus operation on your time variable, dividing your current time by your total duration and using the remainder, which automatically wraps your countdown back to its starting value every time it would otherwise reach zero.
Yes, applying a similar expression to your progress bar's scale or Trim Paths property, referencing the same underlying remaining time and total duration calculation your countdown text uses, keeps both elements precisely synchronized automatically.
Building a countdown timer through expressions rather than manual keyframing gives you a genuinely flexible, easily adjustable result, one where changing your total duration, toggling count direction, or adding synchronized visual elements like a progress bar or final moments color change all flow naturally from a single well built underlying expression rather than requiring extensive manual rework. Once the core logic genuinely clicks, this same expression driven approach extends naturally to a wide range of other time based motion graphics work beyond countdowns specifically.
Investing the extra time to expose your controls properly and save a finished timer as a genuine reusable template, rather than treating each new countdown as a one off build, is what ultimately turns this specific technique from a single useful trick into a lasting, dependable part of your regular motion graphics toolkit, one you can confidently reach for on every future project needing this kind of dynamic, precisely timed element.

To use this expression, you first need to create a text layer. You can do this by going to the toolbar at the top of the screen, selecting the text tool (or pressing 'Ctrl + T' on Windows or 'Cmd + T' on Mac), and clicking on your composition to start typing.
Once you have your text layer, you’ll want to open up the expressions panel. If it’s not already visible, you can find it under 'Window' in the top menu, and then selecting 'Expressions'. With your text layer selected, hold down the 'Alt' key (or 'Option' on Mac) and click on the stopwatch icon next to the 'Source Text' property. This will enable expressions for this property.
In the expressions editor that appears, you can type in the countdown expression. The basic structure of the expression allows you to set a specific duration for the countdown, and it will automatically calculate the remaining time based on the current time indicator's position. The expression typically uses JavaScript math functions to perform these calculations.
It’s crucial to set everything up correctly to ensure that the countdown works as intended. You can tweak the expression to customize the format of the countdown, such as showing days, hours, minutes, or seconds, and you can also add text before or after the countdown numbers to provide additional context.
Using various render passes, you can further enhance the countdown timer by adding effects, colors, and glows, ensuring that it blends seamlessly with the rest of your composition. This approach allows you to make creative decisions at this phase, tweaking the appearance of the countdown timer until it perfectly suits your vision.
Use the following expression to create a straightforward 10-second countdown:
var duration = 10;
Math.max(0, Math.ceil(duration - time));
This displays numbers counting down from 10 to 0.
To display time in a "minutes:seconds" format, use:
var duration = 75; // Countdown duration in seconds
var timeLeft = Math.max(0, duration - time);
var minutes = Math.floor(timeLeft / 60);
var seconds = Math.floor(timeLeft % 60);
minutes + ":" + (seconds < 10 ? "0" : "") + seconds;
This example creates a countdown starting from 1:15 (1 minute and 15 seconds).
For a countdown that resets every 10 seconds:
var duration = 10;
Math.ceil(duration - (time % duration));
This creates a continuous looping countdown from 10 to 0.
You can sync your countdown with a progress bar using expressions like this for the bar’s scale:
var duration = 10;
var progress = Math.max(0, (duration - time) / duration);
[progress * 100, 100];
This ensures that the progress bar decreases in sync with the countdown timer.
You can link the countdown timer to other properties or animations. For instance, sync it with a progress bar or scale a layer dynamically as the countdown progresses.
To create a looping countdown, use a modulus operation:
var duration = 10; // Countdown duration in seconds
Math.ceil(duration - (time % duration));
Pair your countdown animation with a ticking sound or a buzzer at the end. This enhances the impact and provides auditory cues for your audience.
Enhance your countdown by animating the text color as the timer counts down. For example, you can change the color to red when the timer reaches the last few seconds:
if (time > duration - 3) {
[1, 0, 0]; // Red color
} else {
[1, 1, 1]; // White color
}
Make your countdown more engaging by scaling the text as the timer counts down. For example:
var maxScale = 200; // Maximum scale value
var scaleValue = linear(time, 0, duration, maxScale, 100);
[scaleValue, scaleValue];
This creates a dramatic shrinking effect as the timer progresses.
Fade out the text as the countdown ends for a smooth transition:
linear(time, duration - 1, duration, 100, 0);
This expression reduces the opacity from 100% to 0% in the final second of the countdown.