1: After Effects Expressions for Beginners - What they are and How to Add One

For a long time I just didn't touch After Effects expressions. I knew they did something useful, I just never bothered learning them. Then I built a chart with 30 bars that all needed the same animation, and keyframing each one by hand turned out to be a special kind of punishment.

This series is the walkthrough I wish I'd had. Five parts, no computer science degree required. Part 1 covers what an expression actually is, how to add one, and the few UI details matter most.

What an After Effects expression actually is

An expression is a short piece of JavaScript attached to a single property: Position, Rotation, Opacity, a slider on an effect, whatever. On every frame, After Effects runs that code and uses the result as the property's value at that moment.

A script tells the application to do something (import files, build comps, rename 400 layers). An expression tells a property to do something. Say a ball moves from left to right and you want it to shake a little along the way. You don't keyframe the shake. You put a wiggle expression on Position and let it handle the chaos.

What that gets you in practice:

  • Fewer keyframes. Shakes, flickers, bounces and endless loops without hand-placing hundreds of keys.

  • Linked properties. One layer's rotation drives another layer's position, even across comps.

  • Control rigs. A few sliders on one layer run an entire animation.

  • Data-driven graphics. Charts that update when the numbers change, instead of when you rebuild them.

  • Templates. Practically every decent MOGRT has expressions doing the heavy lifting behind the Essential Graphics panel.

And no, you don't need to know JavaScript to get started. You need to know where to click, and how not to panic when numbers turn red.

How to add an expression in After Effects

Quick setup so you can follow along:

  1. Create a new comp, then choose Layer > New > Solid.

  2. Select the solid in the Timeline and press P to show Position.

  3. Alt-click (Windows) or Option-click (macOS) the stopwatch next to Position.

That's it. You've added an expression.

The menu route works too: select the property and choose Animation > Add Expression. To remove it, Alt/Option-click the stopwatch again or use Animation > Remove Expression.

Any property you can keyframe can take an expression. If it has a stopwatch, it's fair game.

Why the numbers turned red

Two things change the moment you add an expression.

First, the property value turns from blue to red. Red means an expression is now deciding that number, and whatever you type manually is being overruled. It's not an error. Red is fine. Red is good.

Second, four small buttons appear under the property :

  • Enable Expression (the = sign) turns the expression on and off without deleting it. It's crossed out when disabled. Honestly your best debugging tool.

  • Show Post-Expression Graph displays what the expression does to the value over time in the Graph Editor.

  • Expression pick whip (the spiral) lets you drag a link to another property. Part 3 is all about this one.

  • Expression Language menu (the little arrow) is a browsable list of everything the expression language offers.

Next to the buttons you'll see the default expression, transform.position. All it does is return the property's own value. It's a placeholder that changes nothing.

Writing your first expression

Click into that text field, replace the default, and type:

wiggle(3,50)

Click anywhere outside the field and hit play. Your solid now jitters around its original spot three times per second, up to 50 pixels in any direction. Zero keyframes.

Two editing quirks:

Clicking in selects everything. When you click into the expression field, After Effects selects the entire expression. Start typing and it's gone. To add to an existing expression, click again to place the cursor first.
Undo exists, sure, but you'll still do this about fifty times before it becomes muscle memory.

The main Enter key doesn't commit. Regular Enter/Return adds a new line, because expressions can span several lines. To leave the field and apply the expression, click outside it or press Enter on the numeric keypad. No numpad on your laptop? Clicking outside it is.

You can also drag the top or bottom edge of the field to make it taller, which you'll want as soon as expressions grow past one line.

The Expression Language menu is underrated

Most tutorials skip that little arrow. For beginners, I'd argue it's the most useful button in the row. It's a live reference of every object, attribute and method you can use, with the correct syntax. Pick an item and After Effects inserts it at your cursor.

The insertion rules are worth knowing:

  • Cursor in the field: the text goes in at the cursor.

  • Text selected: the new text replaces the selection.

  • Cursor not in the field at all: it replaces the whole expression. That's a fun surprise the first time.

When you can't remember whether it's loopOut or loopout (it's loopOut, and yes, capitalization matters), the menu is faster than a search engine.

Make the editor easier on your eyes

The look of the expression editor lives in the preferences under Scripting & Expressions: on macOS via After Effects > Settings, on Windows via Edit > Preferences. If you're squinting at tiny monospace text on a 4K monitor, fix that before anything else.
You'll be reading a lot of it.

Up next

Part 2 looks at how expressions and keyframes work together, plus the three expressions you'll use more than all the others combined:

wiggle, time and loopOut.

Next
Next

Count UP MOGRT