skip to Main Content

After Effects Expressions & JavaScript

framesToTime( )

Edited for clarity: 13 August 2021

The expression framesToTime( ) will convert a number to a time value. The time conversion is based on the frame rate of the composition, or a frame rate you set within the expression.

In other words: the number being converted will be the frame you want After Effects to display. This frame number will be converted into a time value based on the desired frames per second so that After Effects knows where on the timeline that frame falls. Usually you would be using a range of frames, controlled by a variable, which will be converted into a time sequence (see the example below).

Expression form:

framesToTime(frames, fps=1.0/thisComp.frameDuration)

frames is a number representing a frame count. It does not have to be a whole number.

fps=1.0/thisComp.frameDuration is a number expressed in frames per second; in other words the frame rate. If this argument is omitted, and I usually do, the frame rate defaults to the composition’s settings.

thisComp is the current composition that contains the expression.

frameDuration returns the duration of a frame.

Expression  explained:

The frames argument is the frame number, almost always represented by a variable that can change value, converted into a time value based on the frame rate. The frame rate is calculated by determining the duration of a single frame (frameDuration) and dividing 1 by that number.


A number representing a time value.

Example 1

You have a composition which contains an animation that is 60 frames long placed in your main composition. You want to be able to control that animation with a slider, and so you connect a slider with a value range of 0 through 59 (After Effects starts its  frame count at 0). In order for the animation to play properly, you need to activate Time Remapping on the animated composition (Layer > Time > Enable Time Remapping or right-click on animation compostion > Time > Enable Time Remapping) and connect the slider with an expression that converts frames (slider reading) to time (so the animated composition knows where on the timeline you want to be.

S=Pick whip the slider value here.;

//This can also be written like the following

framesToTime(Pick whip the slider value here.)


As you move the slider, either manually or using keyframes, it determines what frame the animation is showing. By using the slider you can control the direction and speed of the animation throughout the main composition’s playing time.

Back To Top