Quickly create complex layer arrays in After Effects with the index expression. Instead of wasting time tweaking the properties of individual duplicate layers, you can completely automate each new layer to change using this expression.

Say you want to duplicate a layer, with each new layer offset by a certain rotation, to create something like a simple flower. Normally, this would require painstakingly clicking each layer and adjusting its rotation one by one.

Below: Manually rotating each new layer.

Index Expression in After Effects: Manually rotating each new layer.

With the index expression applied correctly, each new duplicate of your layer will automatically rotate for you. As you can see, this method is much more efficient.

Below: Duplicating layers using the index expression.

Index Expression in After Effects: Duplicating layers using the index expression.

Now that you understand the usefulness of the index expression in everyday situations, let’s take a look at how to apply it.


What Does “Index” Mean?

The index expression refers to a layer’s assigned number within a composition. For instance, the very topmost layer would have an index of 1, with the layer below it having an index of 2, and so on.

By default, After Effects displays the Layer Number to the left of the Layer Name. If for some reason it isn’t visible, you can enable it by right-clicking one of the composition columns, and enabling the “#” column.

Index Expression in After Effects: What does "index" mean?


How To Use the Index Expression

In most cases, you will start with the expression (Index-1). This will establish a change each time the layer is duplicated. Say you were to apply (Index-1) to the rotation property of a layer. This would cause each new layer to rotate 1 degree further than the previous.

Index Expression in After Effects: How to use the index expression.

You can increase the amount of rotation by multiplying your index value, or you can decrease it by dividing. For example, (Index-1)*30 would increase each new layer’s rotation by 30 degrees, whereas (Index-1)/30 would increase each new layer’s rotation by 1/30th of a degree.

Index Expression in After Effects: How to use the index expression, step 2.

You’ll soon realize that using some basic mathematical logic, you can apply the index expression in a variety of creative ways to speed up your workflow.


Applying To Multi-Dimensional Properties

One-dimensional properties like rotation are fairly straightforward, but using this expression with two-dimensional and three-dimensional properties such as scale and position is slightly more complex. Let’s use the scale properties of a 2D layer, which are Width (X-axis) and Height (Y-axis), as an example. Defining your X and Y properties would look like this:

[value[0], value[1]];

Value[0] is the X-value, and value[1] is the Y-value. Here is an example with real scale values:

[50, 100];

This would set the layer’s scale to 50% width and 100% height. With numeric values, you don’t have to include the [0] or [1] designation. If these designations are referenced within a variable, you won’t need to specify them in the final value brackets either.


Uniform 2D Properties

To increase overall scale by, say, 10% each duplication, you would need to apply the same expression to both of these scale axes. Replacing key expressions with variables can better organize the final code as well. Here are examples both with and without variables.

Without Variable:

[((index-1)*10), ((index-1)*10)];

With Variable:

x = (index-1)*10;

[x, x];

Below: When applied to scale, this expression will increase each new layer’s scale by 10%.

Index Expression in After Effects: Uniform 2D

As you can see, in the Variable Example we established our index expression as “x” in the first line, and were able to apply it to both the width and height of the layer in the second line. This can clean up your expression and save you some time copying and pasting segments of code.


Non-Uniform 2D Properties

If you only want to affect the height (Y-axis) of your layer, your expression would look like this:

b = (index-1)*10;

[value[0], b];

Index Expression in After Effects: non-Uniform 2D


Axis Exceptions

Value[0] represents the current scale input value for width. In other words, if you were to enter the expression [value[0], value[1]], your layer would not be affected at all.

If your layer’s current scale is 13% width, and 37% height, then value[0] would equal 13 and value[1] would equal 37. Value expressions show whatever the current value is, and will change according to keyframes as well.


3D Properties

The properties of 3D layers work under the same logic as 2D layer properties. For instance, the expression for input scale on a 2D object would be [value[0], value[1]] whereas the expression for a 3D object would look like [value[0], value[1], value[2]].

The designation [0] refers to the X-axis, while [1] refers to the Y-axis and [2] refers to the Z-axis. Therefore, you would replace any of the axes you want to modify with your expression, or its assigned variable.

Increasing the position of all axes by 200 pixels would be achieved with this expression:

x = value[0] + (index-1)*200;

[x, x, x];

Index Expression in After Effects: 3D Properties

You can even apply a different expression to each axis.

a = value[0] + (index-1)*200;

b = value[1] + (index-1)*400;

c = value[2] + (index-1)*600;

[a, b, c];

Index Expression in After Effects: 3D Properties, step 2


Decreasing Properties

If you want a layer’s property to decrease with each copy instead of increase, you’ll just need to add one more simple line to your expression. To decrease a layer’s rotation by 5 degrees each duplicate, your expression would look like this:

x = (index-1)*5;

value – x;

Index Expression in After Effects: decreasing properties

This takes the resulting value of your Index expression (which here is defined as X), and subtracts it from the current property value of your first layer.


Setting Start Values

The below expression would increase your property as normal, but would allow you to adjust the starting point for your first layer.

x = (index-1)*5;

value + x;

Index Expression in After Effects: Setting start values

If the expression did not include the secondary line, your first layer would start with your Index Value by default. What this means is if the layer is #8, your expression would be the result of (8-1)*5, which is 35.

value + x; adds the value of “x” to the property’s original value, instead of replacing that value.

Index Expression in After Effects: Setting start values, step 2

The “-1” in (Index-1) is included to reduce the Index Value of your first layer to 0, so that 0 is your starting value instead of 1. If your layer is #7, changing your expression to (Index-7) would ensure your Index Value within the expression starts at 0. Conversely, you could change it to (Index+7) and your Index Value would start at 14.


Advanced Application

You can use this expression on multiple properties of the same layer, so that your layer perhaps doubles in size and rotates 90 degrees each duplication, or maybe moves 500 horizontal pixels and decreases opacity by 10% each time.

You can even apply this to effect properties, like the Colorize Hue Angle Control of the Hue/Saturation effect, which would offset the color of each new layer.

Index Expression in After Effects: Advanced Application

You can get mathematically creative as well – for instance, you can multiple an index phrase by itself to create an exponential increase or decrease of a layer property.


While the math inherently involved in using this expression might be discouraging at first, you’ll quickly come to appreciate the time it saves you in the future.

What cool ways have you applied this expression? Let us know in the comments below.