After Effects Expressions for Beginners: The 10 You’ll Actually Use
What expressions are, how to add them, and ten ready-to-paste After Effects expressions — wiggle, loopOut, time, counters, delays and bounce — explained.
Expressions are small pieces of JavaScript that drive a property in After Effects instead of keyframes. They sound intimidating, but a handful of them cover most everyday needs: endless loops, natural wobble, counters, delays, bounces. This guide explains how expressions work and gives you the ten you'll actually use, ready to copy.
What is an expression?
Every animatable property in After Effects — position, rotation, opacity, a slider — can be controlled by an expression. The expression is evaluated on every frame, and whatever value it returns becomes the property's value. Keyframes still work underneath: an expression can read them, modify them, or ignore them entirely.
Expressions are great for things that are tedious with keyframes: anything that repeats, depends on time, reacts to another layer, or needs to stay in sync when you change one value.
How to add an expression
- Select a property in the timeline (for example, Rotation).
- Hold Alt (Windows) or Option (Mac) and click the stopwatch next to it.
- A text field opens under the property: type or paste the expression.
- Click outside the field. If something is wrong, After Effects shows an error banner with the line at fault.
The pick whip (the spiral icon) lets you link to another property without typing its path: drag it onto the property you want to reference.
The 10 expressions every beginner should know
1. wiggle — natural random motion
wiggle(2, 30)
Moves the property randomly: the first number is how many times per second, the second is how far. Perfect for camera shake, floating elements or flickering lights. On a position property, wiggle(1, 15) gives a gentle drift.
2. loopOut — endless loops
loopOut("cycle")
Repeats your keyframes forever after the last one. Use "pingpong" to play back and forth, "offset" to keep accumulating (great for walk cycles moving forward), or "continue" to keep the last velocity. loopIn() does the same before the first keyframe.
3. time — constant motion
time * 90
time is the current time in seconds. On Rotation, time * 90 turns the layer 90 degrees per second, forever, with no keyframes. On Position, add it to the current value: value + [time * 50, 0] slides a layer to the right at 50 pixels per second.
4. value — keep the keyframes and add to them
value + [0, Math.sin(time * 3) * 20]
value is the property's own value (keyframed or not). Adding to it keeps your animation and layers extra motion on top — here, a soft vertical bob.
5. linear and ease — map one range to another
linear(time, 0, 2, 0, 100)
Goes from 0 to 100 as time goes from 0 to 2 seconds, then holds. ease(), easeIn() and easeOut() do the same with smoothed curves. They're the backbone of rigs: map a slider, a distance or an audio level to any property.
6. A counter for numbers
Math.round(linear(time, 0, 3, 0, 2500))
On a text layer's Source Text, this counts from 0 to 2,500 in three seconds — ideal for stats and infographics. Combine it with a slider (Effect > Expression Controls > Slider Control) to animate the number with keyframes instead.
7. Delay a follower layer
thisComp.layer(index - 1).transform.position.valueAtTime(time - 0.1)
Each layer copies the position of the layer above it, a tenth of a second later. Duplicate the layer a few times and you get a trail. index is the layer's number in the timeline, so the same expression works on every copy.
8. clamp — keep a value in bounds
clamp(value, 0, 100)
Keeps the result between 0 and 100. Useful when another expression or a wiggle might push opacity, scale or a slider out of range.
9. posterizeTime — the stop-motion look
posterizeTime(12);
wiggle(3, 20)
Makes the expression update only 12 times per second, for a choppy, hand-made feel. Put it on the first line of any expression.
10. Inertial bounce — overshoot after a keyframe
n = 0;
if (numKeys > 0) {
n = nearestKey(time).index;
if (key(n).time > time) n--;
}
t = n == 0 ? 0 : time - key(n).time;
if (n > 0 && t < 1) {
v = velocityAtTime(key(n).time - thisComp.frameDuration / 10);
amp = 0.06; freq = 3; decay = 5;
value + v * amp * Math.sin(freq * t * 2 * Math.PI) / Math.exp(decay * t);
} else {
value;
}
A classic: after each keyframe, the property overshoots and settles with a springy bounce. Tweak amp (how far), freq (how fast) and decay (how quickly it calms down). Works on position, scale and rotation.
Expression controls: make them adjustable
Hard-coded numbers are fine to start, but expression controls make your work reusable. Add a Slider Control to a layer, then pick-whip it in your expression:
wiggle(effect("Frequency")("Slider"), effect("Amount")("Slider"))
Now anyone can tune the wiggle without touching code — and you can keyframe the sliders. This is how templates and rigs are built.
Common mistakes
- Dimension mismatches. Position and scale are arrays (
[x, y]); rotation and opacity are single numbers. Adding a number to an array, or the reverse, causes errors. - Straight quotes. Copying from some websites brings curly quotes; After Effects needs straight ones (
"cycle"). - Renamed layers and effects. Expressions reference names: rename a layer and links can break. Using
indexor the pick whip limits the damage. - Separated dimensions. If Position is split into X and Y, each one needs its own single-number expression.
Where to go next
Once these ten feel natural, explore valueAtTime() for echoes, toComp() to follow layers in 3D, and audio-driven animation with the Convert Audio to Keyframes command. Motionimo's After Effects expressions library collects more than a hundred ready-to-paste expressions for loops, text, rigs and more — each one explained.
And if you're weighing up your tools, our comparison of Cavalry and After Effects shows when a procedural tool can replace a pile of expressions.
Frequently asked questions
Do I need to know JavaScript to use expressions?
No. Most motion designers start by copying a few expressions and adjusting the numbers. Learning a little JavaScript later helps you write your own.
Do expressions slow down After Effects?
Simple ones barely affect performance. Complex expressions on hundreds of layers, or ones that sample other layers through time, can slow previews; baking them into keyframes (Animation > Keyframe Assistant > Convert Expression to Keyframes) fixes that.
Can I use expressions with keyframes?
Yes. Through value, an expression can build on top of your keyframes, and loops like loopOut() rely on them.