Automatically repeats your animation based on keyframes using built-in loop expressions. Great for cycles, continuous motion, or back-and-forth effects.
loopOut()
// Repeats the animation after the last keyframe using the default loop type
You can apply loop expressions to any property with a stopwatch (not just Position, Scale, or Rotation). It works on Opacity, Effects (like Blur), Masks, and more. If it has keyframes, it can loop.
The loopOut()
expression is the simplest form of a loop. It tells After Effects to repeat your animation after the last keyframe using the default loop type, which is "cycle."
If you’ve keyframed an animation (like bouncing a ball) and want it to repeat over and over after the last keyframe, just drop this in. No need to touch the timing.
Let’s break down all the different types of loop expressions you can use in After Effects.
loopOut("cycle")
loopOut("cycle") // Loops the keyframed animation after the last keyframe in a cycle
Any animated property: Position, Opacity, Scale, Effects, etc.
This is the default loop type. Say you have 4 position keyframes that move an object up and down. When it gets to the last keyframe, it jumps back to the start and repeats the movement exactly the same way. There’s no blending. It just loops the same motion again and again.
loopOut("pingpong")
loopOut("pingpong") // Loops forward then reverses the animation after the last keyframe
Any property with keyframes that you want to play forward, then backward, over and over.
Perfect for seamless back-and-forth motion. Let’s say you keyframe an object moving from left to right. With "pingpong" it’ll go right, then left, then right again (without needing extra keyframes).
loopOut("offset")
loopOut("offset") // Loops the motion, but offsets the value so it keeps increasing or decreasing
Usually used on properties like Position, Rotation, or Scale.
This repeats your animation while adding the difference in value between loops.
So if an object moves 100px up between two keyframes, each loop adds another 100px. That creates a stair-step movement or endless scroll.
loopOut("continue")
loopOut("continue") // Keeps moving based on the velocity of the last keyframe
Works great on linear motion properties like Position or Rotation.
Instead of repeating or offsetting keyframes, this tells After Effects to keep going in the same direction and speed after the last keyframe. It uses the movement trend to predict what should happen next.
loopIn("cycle")
loopIn("cycle") // Cycles the animation before the first keyframe
Useful when your animation needs to look like it started before the comp's timeline.
Instead of looping after the animation, this loops the motion before your first keyframe.
Say your animation starts at frame 30, but you want it to feel like it was always moving before that. This is what you use.
loopOut("cycle", 2)
loopOut("cycle", 2) // Loops only the last 2 keyframes in a cycle
Same as the rest (works on any keyframed property).
The second number controls how many keyframes to include in the loop. In this example, After Effects will only loop the last two keyframes, ignoring any setup or earlier animation.
Just copy the full expression code from the top of this page. Then Alt-click (or Option-click on Mac) the stopwatch on the property you want to animate. Paste the code into the editor and that's it. If you’re not sure which property to use, check the "Where to Apply" section above.
First, make sure your project is using the JavaScript engine (go to File > Project Settings > Expressions). Also double-check for missing characters, and see if the code requires parenting a layer. If so, there will be a comment in the code explaining what needs to be connected.
Take a look at the "How It Works" section on this page. It explains each part of the expression in plain language so you can understand how everything works together.
Yes, absolutely. Most expressions include easy-to-edit variables near the top and comments that guide you on what to change. You can also link sliders or checkboxes using Expression Controls if you want more control in the timeline.
Yes, you can use it on any property with a stopwatch. That includes Position, Scale, Opacity, and also effect settings like Blur or Tint.
In most cases, yes. These expressions are designed to adapt to your comp’s resolution and frame rate. If anything specific needs adjusting, it’ll be noted in the code or in the "How It Works" section.