How to Add Expression in After Effects
StyleFrame Team8 min read
To add an expression in After Effects, select a layer, reveal the property you want (for example, press P for Position), and Alt-click (Windows) or Option-click (Mac) the stopwatch next to it. A text field opens in the timeline where you type or paste code, such as wiggle(2, 20). Click outside the field to apply it, and Alt/Option-click the stopwatch again to remove it.
Add an Expression Step by Step
Here is the full process, using a simple shape layer as the test subject.
- Create or select a layer. Any layer works. A shape layer, text layer, solid, null, or footage item all accept expressions.
- Reveal the property. Use the single-key shortcuts: P for Position, S for Scale, R for Rotation, A for Anchor Point, T for Opacity. Add Shift to show a second property alongside the first.
- Alt/Option-click the stopwatch. The property values turn red, and an expression field appears to the right in the timeline. Without the modifier key, you create a keyframe instead.
- Type the expression. For a first test, enter
wiggle(3, 25)on Position. That gives roughly three random movements per second, up to 25 pixels in either direction. - Commit it. Click outside the text field, or press Enter on the numeric keypad. Plain Return just adds a new line.
- Preview. Scrub or press the spacebar. If the text turns up with a yellow warning icon, the expression has an error (covered below).
Expressions can also live on effect parameters, such as the Evolution value in Fractal Noise or Turbulent Displace, on text animators, and on layer styles. The workflow is identical: if a property has a stopwatch, it accepts an expression.
Other Ways to Create an Expression
Typing is not the only route, and professionals mix all of these depending on the job.
The Pick Whip
The pick whip (the spiral icon next to the expression field) writes the property reference for you. Drag it from one property to another and After Effects inserts the correct code, so you don't have to hand-type layer and property names. This is how you make one layer follow another's rotation or tie an opacity value to a slider.
The Expression Language Menu
The small arrow icon beside the field opens a categorized list of built-in JavaScript functions and attributes. It is useful when you remember that something exists, such as linear(), ease(), or clamp(), but not its exact syntax. Choosing an entry inserts it at the cursor.
Expression Controls
Go to Effect > Expression Controls to add Slider, Checkbox, Color, Point, Angle, Layer, and Dropdown Menu controls. These do nothing on their own. They hold values that your expressions read. A typical setup:
- Add three Slider Controls to a layer and rename them Frequency, Amplitude, and Octaves.
- Alt/Option-click the stopwatch on Position and type
wiggle(0, 0, 0). - Select each number in turn and drag the pick whip to the matching slider.
- Set the sliders to something like 2, 20, and 3.
You now have a tweakable wiggle without ever reopening the code. This pattern is the foundation of most rigs and templates, and it pairs well with Essential Properties if you hand work to other artists.
Presets and Copy/Paste
You can copy an expression-bearing property (select it, Ctrl/Cmd+C) and paste it onto another layer. The expression travels with it. Animation presets (.ffx) preserve expressions too.
Five Starter Expressions Worth Knowing
If you only learn a handful, learn these.
Wiggle gives you organic randomness:
wiggle(freq, amp)
You can add octaves and an amplitude multiplier as the third and fourth arguments for more complex noise.
Time produces continuous, linear change without keyframes. On Rotation, time*50 adds 50 degrees per second. On a one-dimensional property, that's all you need.
Time on multidimensional properties. Position and Scale take arrays, so time*200 alone errors out. Either separate the Position dimensions and put time*200 on X, or write the whole array:
[time*200 + 500, value[1]]
Here value[1] keeps the original Y. For Scale, use something like [time*50 + 100, 100], remembering that scale is in percent.
posterizeTime steps an animation down to a lower frame rate for a hand-made, stop-motion feel:
posterizeTime(8); wiggle(2, 30)
It is a useful alternative to adding a Posterize Time effect because you can apply it per property instead of per layer.
loopOut repeats existing keyframes:
loopOut("cycle")
Other modes include "pingpong", "offset", and "continue". This one requires at least two keyframes on the property, otherwise there is nothing to loop.
Edit, Disable, and Remove Expressions
- Edit: Click inside the expression field to place the cursor and type. In current versions of After Effects, you don't need to Alt-click again.
- Show everything: Select a layer and press EE to reveal every property that has an expression. This is the fastest way to audit a comp you inherited.
- Disable temporarily: Click the equals-sign icon next to the stopwatch. The code stays, but the property returns to its underlying value. Great for A/B comparisons.
- Remove: Alt/Option-click the stopwatch again. This deletes the expression and, depending on whether keyframes exist, leaves the property static or keyframed.
- Convert to keyframes: Use Animation > Keyframe Assistant > Convert Expression to Keyframes when you need to bake the result for a render farm, a handoff, or a tool that doesn't read expressions.
Add Comments to Keep Expressions Readable
Comments are plain text that After Effects ignores. Use // for a single line and /* ... */ for multiple lines:
When another artist opens the project six months later (or you do), these notes save real time. Naming your Expression Controls clearly serves the same purpose.
Fixing Common Errors
When something is wrong, After Effects displays a yellow warning banner at the bottom of the Composition panel and a warning icon next to the expression. Click the banner or hover over the icon to see the message and the line number. The usual suspects:
- Dimension mismatch. You returned one number to a two- or three-dimensional property. Return an array, or separate dimensions.
- Missing layer, property, or effect. Someone renamed the target. Expressions referencing names by string break when the name changes. The pick whip generates references, but they are still name-based.
- Typos and unmatched brackets. Case matters.
Wiggleis notwiggle. - Engine differences. In File > Project Settings > Expressions, you can choose between the JavaScript engine and the Legacy ExtendScript engine. Old projects or scripts may depend on the legacy one, and some syntax only works in the modern engine. If a copied snippet fails, check this setting first.
- Missing keyframes. Functions like
loopOut()orvalueAtTime()assume animation exists.
Habits That Keep Expression Work Production-Safe
- Drive values from a single control null or slider rather than burying magic numbers inside multiple layers.
- Prefer relative references (
thisComp.layer("CTRL")) over hard-coded values so duplicating a precomp doesn't break the rig. - Test expressions at different frame rates and comp sizes before handing off.
- Be careful with heavy expressions on many layers. Expressions evaluate per frame, and long chains of
valueAtTime()loops can slow previews. - Bake to keyframes or render image sequences when a shot is locked and needs to move through a pipeline that doesn't evaluate After Effects code.
Where Styleframe Fits Alongside Expressions
Expressions handle procedural motion inside a comp: wiggles, loops, rigs, and linked parameters. They don't generate new imagery. If you need styled plates, a restyled live-action shot, or a 2D asset turned into a 3D turntable to composite into your After Effects project, that is the kind of work is built for.
Styleframe is an AI video and motion tool designed around artistic control rather than one-click output. Generations are driven by your own reference images, video clips, and keyframes, through tools like keyframe-driven Frames-to-Video, Restyle and Ink-and-Paint (reference-driven style transfer), 2D-to-3D, Turntable, Remove Background, and 4K Upscale. Iteration is non-destructive, so you can refine a result without throwing away earlier versions, and output is production-ready 4K.
In practice, you could generate or restyle a background plate in Styleframe, export it as an image sequence, and bring it into After Effects (or Nuke) where your expression-driven rigs, camera shake, and loops take over. Your compositing workflow stays intact, and the image sequence route works with your existing pipeline.
Quick Recap
- Alt/Option-click the stopwatch to create an expression, then click outside the field to apply it.
- Use the pick whip, the Expression Language Menu, and Expression Controls to build expressions without typing everything by hand.
- Learn
wiggle,time,posterizeTime,loopOut, and array syntax first. - Press EE to audit expressions, use the equals icon to toggle them, and add comments so rigs stay maintainable.
- Read the warning banner when something breaks, and check the expression engine setting when pasted code misbehaves.
Once the add-and-edit routine is muscle memory, expressions stop being intimidating code and become another property you animate, one that saves hours on repetitive motion.