How to Master the Loop Expression in After Effects

After Effects 29/12/2020 4 min read

Using After Effects Expressions can be scary at first; it is a bit like coding and can be confusing. Expressions are incredible pieces of code that can save you hours creating complicated repeating animation, so they are well worth learning. One of the most useful  Expressions to learn to use is the After Effects Loop Expression. In this guide, we’re going to take you through not just how to use the AE Loop Expression, but how it works, so you can customize it to your needs.

Part 1: The Structure & Types of the After Effects Loop Expression

The first thing you’ll need to understand is how an Expression is formed. There are 3 distinct sections to any Loop Expression; the Property, the Loop Type, and the Modifier. Together, these three elements create a command that After Effects can use to loop your keyframes in several ways.

One of the most used Expressions in animation is the Loop Out Ping Pong effect, which we will use for this example.


The Property – loopOut(“pingpong”,1)

There are four types of Loop Expression properties.

 LoopOut and LoopIn: As you can probably guess, each of these Loop types tells After Effects whether the loop starts before or after your keyframes.

LoopOutDuration and LoopInDuration: These two are slightly different, as they allow you to tell After Effects to base the loop on Seconds rather than Keyframes. To do this, you’ll need to add a modifier, which we will discuss below. In general, the Duration loops are not massively helpful but can save you a lot of time if, for example, you want to be able to quickly adjust how long the loop takes without changing your keyframes.

Loop Type – loopOut(“pingpong”,1)

The Loop Type is where you decide the type of animated loop After Effects will create. There are four Loop Types available;


The PingPong loop will take your first and last Keyframe and move back and forth between them.


The Cycle Loop repeats your keyframe in order over and over again. If your last keyframe has the same values as your first Keyframe, AE will create a never-ending animation loop, repeating over and over again.


The Offset Loop is a little challenging to understand but incredibly powerful in use. Essentially the Offset loop repeats your Keyframed animation but Offsets it, so it begins again from the last keyframe. Confused? We don’t blame you – check out the example to see it in action.


The Continue loop type can help to tie up the ends of animated scenes when you want everything to disappear neatly from the screen at the same time. This Loop Type continues the speed/value of your last Keyframe; the animation just keeps going forever, or until you decide to put an end to it.

Modifier –  loopOut(“pingpong”,1)

The Modifier is the final instruction to After Effects, and in some cases, it is not needed at all. When using the Duration based Properties, the Modifier will instruct AE on the number of seconds to repeat. 

For the Loop In and Out expressions, the Modifier can be used to tell AE how many of your Keyframes you want to apply the loop to. It is essential to note that the number doesn’t directly refer to the Keyframes but to the animated section between Keyframes.

For example, if you use the Loop Out property with a Modifier of one, AE will repeat the animation between the last two Keyframes in the timeline. If you use a Modifier of 2, AE will repeat the animation between the previous 3 Keyframes.

Part 2: How to Use Loop Expression in After Effects

Loop Expressions can be used on any value to which you can add a Keyframe. In this example, we are adding the Expression to the Position Value, but there are many more values you can play with.

  1. Create your Keyframes as with any standard animation project.
  2. Select the Value you want to add an Expression to in the Timeline.
  3. Go to Animation > Add Expression. You can also hold Alt and hit the Stopwatch icon alongside the Value.
  4. In the Box on the Timeline, type, or paste in your Expression. You will notice After Effect predicts what you want to use and gives you a handy drop down to select elements from.
  5. Check your animation and add a modifier if you need to.

Top Tip: If you have applied your Expression and want to adjust your Keyframes, it can be a bit tricky to see what is happening. Us the = button next to the Expression to turn it on and off, rather than deleting your Expression to make adjustments.

Part 3: Creative Ways to Use the Loop Expression in After Effects

Now you know how to use Loop Expressions, you might be thinking of all the instances they could have saved you time in the past. Don’t worry; there are plenty more projects to test your new skills on.

Use Expressions on a Variety of Values

You can use more than one Expression on each element, for example, changing the size and position in different ways. Using Loop Expressions in this way can help create repeating motion backgrounds or simple elements like clouds passing in a scene.

Typography Projects

Loop Expressions can be used to turn Text Transition into incredible Text Effects with a simple PingPong Expression. Add your Text Transition and create new keyframes for where you want the animation to repeat. Add a Modifier to your Expression to loop the part of the transition you want to repeat.

Use with other Effects

Using Expressions doesn’t prevent you from using other Effects on your elements. A beneficial and fun Effect to use with Expression is the RepeTile effect, allowing you to create complex background graphics quickly.

Expressions are a powerful but often neglected tool for any animator working in After Effects. Once you get the hang of creating these simple Expressions, you can begin to experiment and combine them to create cool effects with just a tiny piece of code.

After Effect Loop Expressions are one of the handiest types of Expression to learn and can save you a lot of time with complicated keyframing, now you know the basics, why not find out more with these 6 Common After Effects Expressions you should be using.

Share this article: