Your screen is too tiny!

The expressions page is currently only formatted for desktop browsers.

Try making your screen size bigger.

Plus, why are you looking at AE Expressions on a phone? That's kinda dorky.
Expression Copied to Clipboard! 🗂
2D to 3D Null
Attach a 2D position a 3D Null
thisComp.layer("3D Layer Name").toComp([0,0,0]);
Auto Fade In & Out by Marker Duration
Fade a layer in and out using markers to set the duration
fadeFrames = 6; m = 0; t=time; if(marker.numKeys > 0) { m = marker.nearestKey(time).index; tag = marker.key(m).comment; if(tag == 'Highlight'){ tMin = marker.key(m).time; tMax = tMin + marker.key(m).duration; if(t < tMin){ linear(time, tMin - framesToTime(fadeFrames), tMin, 0, value); } else { linear(time, tMax - framesToTime(fadeFrames), tMax, value, 0); } } else { value; } } else {value}
Center Anchor Point Vertically on Text
Make the anchor point always vertically centered on a text layer
y=value[1]-sourceRectAtTime(time).height/2; [0,y]
Control Property with Checkbox
Apply this expression to the property you want to control (like opacity) and make sure it is referencing the correct control layer.
thisComp.layer("Controls").effect("Control Name")("Checkbox") * value;
Control Shape Layer Position with Null
Control shape layer position with a Null - works like parenting, but keeps the relative position of your shape layer.
control=thisComp.layer("Control NULL"); // your controller null controlPos = control.toComp(control.transform.anchorPoint); fromComp(controlPos) // apply to position property
Delay
Delay property by certain number of frames
delay = 5; //number of frames to delay d = delay*thisComp.frameDuration*(index - 1); thisComp.layer(1).rotation.valueAtTime(time - d)
Delay Keyframes With Slider
Use a slider control to delay keyframe animation by a defined amount of seconds. Works like a marker trigger, but simpler. Useful for MOGRTs
delay = thisComp.layer("Controls").effect("Delay")("Slider"); // pickwhip to your Delay Slider (in seconds) valueAtTime(time-delay)
Dropdown Menu Select
Control the opacity of a layer by the dropdown menu selection. Add a Number [1,2,3,etc] to the beginning of layer to make it work
select = thisComp.layer("CONTROLS").effect("Face Select")("Menu"); (select == parseInt(thisLayer.name[0])) ? value : 0;
Frozen Random Number
Generate a random number
seedRandom(index,true); myValue = random(50) ;
Get Current Date and Format
Useful snippet for getting current date
d = new Date(Date(0)); // Format Settings divider = "/" yearLength = 2; // use 2 for YY, 4 for YYYY function padZeros(n){ if(n <= 9){ return "0" + n; } return n } yearTrim = (yearLength===2) ? 2 : 0; "" + padZeros(d.getMonth()+1) + divider + padZeros(d.getDate()) + divider + d.getFullYear().toString().substring(yearTrim,4);
Ignore Parent Rotation
Keep the current rotation of child, even when parent rotates.
value - parent.transform.rotation
Ignore Parent Scale
Maintain scale of a layer when parented to another layer. Apply to scale property of child layer.
s = []; parentScale = parent.transform.scale.value; for (i = 0; i < parentScale.length; i++){ s[i] = (parentScale[i]== 0) ? 0 : value[i]*100/parentScale[i]; } s
Ignore Parent Scale (if parent has parent)
Maintain scale of a layer when parented to another layer - even if that layer has a parent. Apply to scale property of child layer.
L = thisLayer; s = transform.scale.value; while (L.hasParent){ L = L.parent; for (i = 0; i < s.length; i++) s[i] *= 100/L.transform.scale.value[i] } s
Inherit Parent Opacity
Inherit Opacity from parent layer
(hasParent) ? parent.opacity : value;
Inherit Parent Opacity (editable)
Inherits opacity from parent but retains the child's editabilty
(hasParent) ? (parent.opacity/100) * value : value;
Invert Opacity
Alternate opacity with the opacity of another layer.
Loop In and Out
Loop an animation both forward and backwards in time
loopIn() + loopOut() - value;
Loop Path Keyframes
Seamlessly loop keyframes on a Path Property for shape layers or masks.
// loop path keyframes. Behaves like loopOut('cycle') if (numKeys >1 && time > key(numKeys).time) { t1 = key(1).time; t2 = key(numKeys).time; span = t2 - t1; delta = time - t2; t = delta%span; valueAtTime(t1 + t) } else { value } // more expressions at aereference.com
Loop a Wiggle
Seamlessly loop a wiggle expression (in seconds)
frequency = 2; // wiggles per second amplitude = 40; // amount of pixels to wiggle secondsToLoop = 3; // time to loop in seconds // -------- t = time % secondsToLoop; wiggle1 = wiggle(frequency, amplitude, 1, 0.5, t); wiggle2 = wiggle(frequency, amplitude, 1, 0.5, t - secondsToLoop); linear(t, 0, secondsToLoop, wiggle1, wiggle2)
Maintain Stroke Width
Maintain stroke width while scaling layers. Apply to stroke width property
Max Width Scale of Text Layer
Constrain the max width of a text layer using the scale property
maxW = effect("max-width")("Slider"); sourceW = sourceRectAtTime(time,true).width; if(sourceW >= maxW ){ s = value[0]*maxW/sourceW; [s,s] } else { value }
Posterize Time + Wiggle
Add a posterize time stop motion effect with the wiggle expression.
f = 2; a = 10; posterizeTime(f); wiggle(f, a);
Scale Layer to a Certain Width
Scale a layer to fit a pixel width. Apply to scale property
Show/Hide Layer With Dropdown
Apply to opacity property of a layer. Change name of layer to start with [1,2,3] to match the Dropdown control.
select = effect("Dropdown Control")("Menu").value; if (select === parseInt(thisLayer.name.charAt(0))){ 100 } else { 0 }
Trigger Expression on Marker
Boilerplate expression to trigger actions with markers
n=0; if(marker.numKeys>0) { n=marker.nearestKey(time).index; if(marker.key(n).time>time) { n--; } if(n==0) { value; } else { t=time-marker.key(n).time; //time since marker //Do Stuff } } else { value; }
Wiggle Between Two Values
Wiggle randomly between two values.
min = -10; // minimum value max = 50; // maximum value freq = 5; // wiggles per second amp = Math.abs(max-min)/2; // amount to wiggle offset = (max+min)/2; wiggle(f, a) + offset;
Wiggle on One Dimension
Constrain wiggle to One Dimension (X or Y). NOTE: Wiggles X dimension. For Y dimension only, change last line to [value[0],w[1]]

2D to 3D Null

Attach a 2D position a 3D Null

thisComp.layer("3D Layer Name").toComp([0,0,0]);

Copied to Clipboard!
thisComp.layer("3D Layer Name").toComp([0,0,0]);

Auto Fade In & Out by Marker Duration

Fade a layer in and out using markers to set the duration

fadeFrames = 6; m = 0; t=time;
if(marker.numKeys > 0) {
m = marker.nearestKey(time).index;
tag = marker.key(m).comment;
if(tag == 'Highlight'){
tMin = marker.key(m).time;
tMax = tMin + marker.key(m).duration;

if(t < tMin){
linear(time, tMin - framesToTime(fadeFrames), tMin, 0, value);
} else {
linear(time, tMax - framesToTime(fadeFrames), tMax, value, 0);
}
} else {
value;
}
} else {value}

Copied to Clipboard!
fadeFrames = 6; m = 0; t=time;
if(marker.numKeys > 0) { m = marker.nearestKey(time).index; tag = marker.key(m).comment; if(tag == 'Highlight'){ tMin = marker.key(m).time; tMax = tMin + marker.key(m).duration; if(t < tMin){ linear(time, tMin - framesToTime(fadeFrames), tMin, 0, value); } else { linear(time, tMax - framesToTime(fadeFrames), tMax, value, 0); } } else { value; }
} else {value}

Center Anchor Point Vertically on Text

Make the anchor point always vertically centered on a text layer

y=value[1]-sourceRectAtTime(time).height/2;
[0,y]

Copied to Clipboard!
y=value[1]-sourceRectAtTime(time).height/2;
[0,y]

Control Property with Checkbox

Apply this expression to the property you want to control (like opacity) and make sure it is referencing the correct control layer.

value * thisComp.layer("Controls").effect("Control Name")("Checkbox"); // replace Checkbox Control with your checkbox control

Copied to Clipboard!
thisComp.layer("Controls").effect("Control Name")("Checkbox") * value;

Control Shape Layer Position with Null

Control shape layer position with a Null - works like parenting, but keeps the relative position of your shape layer.

control=thisComp.layer("Control NULL"); // your controller null
controlPos = control.toComp(control.transform.anchorPoint);
fromComp(controlPos)
// apply to position property

Copied to Clipboard!
control=thisComp.layer("Control NULL"); // your controller null
controlPos = control.toComp(control.transform.anchorPoint);
fromComp(controlPos)
// apply to position property

Delay

Delay property by certain number of frames

delay = 5; //number of frames to delay
d = delay*thisComp.frameDuration*(index - 1);
thisComp.layer(1).rotation.valueAtTime(time - d)

Copied to Clipboard!
delay = 5; //number of frames to delay
d = delay*thisComp.frameDuration*(index - 1);
thisComp.layer(1).rotation.valueAtTime(time - d)

Delay Keyframes With Slider

Use a slider control to delay keyframe animation by a defined amount of seconds. Works like a marker trigger, but simpler. Useful for MOGRTs

delay = thisComp.layer("Controls").effect("Delay")("Slider"); // pickwhip to your Delay Slider (in seconds)
valueAtTime(time-delay)

Copied to Clipboard!
delay = thisComp.layer("Controls").effect("Delay")("Slider"); // pickwhip to your Delay Slider (in seconds) valueAtTime(time-delay)

Dropdown Menu Select

Control the opacity of a layer by the dropdown menu selection. Add a Number [1,2,3,etc] to the beginning of layer to make it work

select = thisComp.layer("CONTROLS").effect("Dropdown")("Menu"); // pick whip to your dropdown
(select == parseInt(thisLayer.name[0])) ? value : 0;

Copied to Clipboard!
select = thisComp.layer("CONTROLS").effect("Face Select")("Menu");
(select == parseInt(thisLayer.name[0])) ? value : 0;

Frozen Random Number

Generate a random number

seedRandom(index,true);
myValue = random(50) ;

Copied to Clipboard!
seedRandom(index,true);
myValue = random(50) ;

Get Current Date and Format

Useful snippet for getting current date

d = new Date(Date(0));
// Format Settings
divider = "/"
yearLength = 2; // use 2 for YY, 4 for YYYY

function padZeros(n){
 if(n <= 9){
   return "0" + n;
 }
 return n
}
yearTrim = (yearLength===2) ? 2 : 0;
"" + padZeros(d.getMonth()+1) + divider + padZeros(d.getDate()) + divider + d.getFullYear().toString().substring(yearTrim,4);

Copied to Clipboard!
d = new Date(Date(0));
// Format Settings
divider = "/"
yearLength = 2; // use 2 for YY, 4 for YYYY function padZeros(n){ if(n <= 9){ return "0" + n; } return n
}
yearTrim = (yearLength===2) ? 2 : 0;
"" + padZeros(d.getMonth()+1) + divider + padZeros(d.getDate()) + divider + d.getFullYear().toString().substring(yearTrim,4);

Ignore Parent Rotation

Keep the current rotation of child, even when parent rotates.

value - parent.transform.rotation

Copied to Clipboard!
value - parent.transform.rotation

Ignore Parent Scale

Maintain scale of a layer when parented to another layer. Apply to scale property of child layer.

s = [];
parentScale = parent.transform.scale.value;
for (i = 0; i < parentScale.length; i++){
s[i] = (parentScale[i]== 0) ? 0 : value[i]*100/parentScale[i];
}
s

Copied to Clipboard!
s = [];
parentScale = parent.transform.scale.value;
for (i = 0; i < parentScale.length; i++){
s[i] = (parentScale[i]== 0) ? 0 : value[i]*100/parentScale[i];
}
s

Ignore Parent Scale (if parent has parent)

Maintain scale of a layer when parented to another layer - even if that layer has a parent. Apply to scale property of child layer.

L = thisLayer;
s = transform.scale.value;
while (L.hasParent){
L = L.parent;
for (i = 0; i < s.length; i++) s[i] *= 100/L.transform.scale.value[i]
}
s

Copied to Clipboard!
L = thisLayer;
s = transform.scale.value;
while (L.hasParent){
L = L.parent;
for (i = 0; i < s.length; i++) s[i] *= 100/L.transform.scale.value[i]
}
s

Inherit Parent Opacity

Inherit Opacity from parent layer

(hasParent) ? parent.opacity : value;

Copied to Clipboard!
(hasParent) ? parent.opacity : value;

Inherit Parent Opacity (editable)

Inherits opacity from parent but retains the child's editabilty

(hasParent) ? (parent.opacity/100) * value : value;

Copied to Clipboard!
(hasParent) ? (parent.opacity/100) * value : value;

Invert Opacity

Alternate opacity with the opacity of another layer.

t = thisComp.layer("Back").transform.opacity // Pickwhip the layer you want to invert

linear(t,0,value,100,0)

Copied to Clipboard!

Loop In and Out

Loop an animation both forward and backwards in time

loopIn() + loopOut() - value;

Copied to Clipboard!
loopIn() + loopOut() - value;

Loop Path Keyframes

Seamlessly loop keyframes on a Path Property for shape layers or masks.

// loop path keyframes. Behaves like loopOut('cycle')
if (numKeys >1 && time > key(numKeys).time) {
t1 = key(1).time;
t2 = key(numKeys).time;
span = t2 - t1;
delta = time - t2;
t = delta%span;
valueAtTime(t1 + t)
} else {
value
}

Copied to Clipboard!
// loop path keyframes. Behaves like loopOut('cycle')
if (numKeys >1 && time > key(numKeys).time) { t1 = key(1).time; t2 = key(numKeys).time; span = t2 - t1; delta = time - t2; t = delta%span; valueAtTime(t1 + t)
} else { value
}
// more expressions at aereference.com

Loop a Wiggle

Seamlessly loop a wiggle expression (in seconds)

frequency = 2; // wiggles per second
amplitude = 40; // amount of pixels to wiggle
secondsToLoop = 3; // time to loop in seconds
// --------
t = time % secondsToLoop;
wiggle1 = wiggle(frequency, amplitude, 1, 0.5, t);
wiggle2 = wiggle(frequency, amplitude, 1, 0.5, t - secondsToLoop);
linear(t, 0,  secondsToLoop, wiggle1, wiggle2)

Copied to Clipboard!
frequency = 2; // wiggles per second
amplitude = 40; // amount of pixels to wiggle
secondsToLoop = 3; // time to loop in seconds
// --------
t = time % secondsToLoop;
wiggle1 = wiggle(frequency, amplitude, 1, 0.5, t);
wiggle2 = wiggle(frequency, amplitude, 1, 0.5, t - secondsToLoop);
linear(t, 0, secondsToLoop, wiggle1, wiggle2)

Maintain Stroke Width

Maintain stroke width while scaling layers. Apply to stroke width property

value / length(toComp([0,0]), toComp([0.7071,0.7071])) || 0.001;

Copied to Clipboard!

Max Width Scale of Text Layer

Constrain the max width of a text layer using the scale property

maxW = effect("max-width")("Slider"); // pick whip to your slider
sourceW = sourceRectAtTime(time,true).width;

if(sourceW >= maxW ){
s = value[0]*maxW/sourceW;
[s,s]
} else {
value
}

Copied to Clipboard!
maxW = effect("max-width")("Slider");
sourceW = sourceRectAtTime(time,true).width; if(sourceW >= maxW ){ s = value[0]*maxW/sourceW;
[s,s]
} else { value
}

Posterize Time + Wiggle

Add a posterize time stop motion effect with the wiggle expression.

f = 2;
a = 10;
posterizeTime(f);
wiggle(f, a);

Copied to Clipboard!
f = 2;
a = 10;
posterizeTime(f);
wiggle(f, a);

Scale Layer to a Certain Width

Scale a layer to fit a pixel width. Apply to scale property

w = 600; // set to your target width
s = 100*w/thisLayer.width;
[s,s]

Copied to Clipboard!

Show/Hide Layer With Dropdown

Apply to opacity property of a layer. Change name of layer to start with [1,2,3] to match the Dropdown control.

select = effect("Dropdown Control")("Menu").value;

if (select === parseInt(thisLayer.name.charAt(0))){ 100 } else { 0 }

Copied to Clipboard!
select = effect("Dropdown Control")("Menu").value; if (select === parseInt(thisLayer.name.charAt(0))){ 100 } else { 0 }

Trigger Expression on Marker

Boilerplate expression to trigger actions with markers

n=0;
if(marker.numKeys>0) {
 n=marker.nearestKey(time).index;
 if(marker.key(n).time>time) {
  n--;
 } if(n==0) {
  value;
 } else {
  t=time-marker.key(n).time; //time since marker
  //Do Stuff
 }
} else {
 value;
}

Copied to Clipboard!
n=0;
if(marker.numKeys>0) { n=marker.nearestKey(time).index; if(marker.key(n).time>time) { n--; } if(n==0) { value; } else { t=time-marker.key(n).time; //time since marker //Do Stuff }
} else { value;
}

Wiggle Between Two Values

Wiggle randomly between two values.

min = -10; // minimum value
max = 50; // maximum value
freq = 5; // wiggles per second
amp = Math.abs(max-min)/2; // amount to wiggle
offset = (max+min)/2;
wiggle(f, a) + offset;

Copied to Clipboard!
min = -10; // minimum value
max = 50; // maximum value
freq = 5; // wiggles per second
amp = Math.abs(max-min)/2; // amount to wiggle
offset = (max+min)/2;
wiggle(f, a) + offset;

Wiggle on One Dimension

Constrain wiggle to One Dimension (X or Y). NOTE: Wiggles X dimension. For Y dimension only, change last line to [value[0],w[1]]

frequency = 2;
amplitude = 10;
w = wiggle(frequency, amplitude);
[w[0],value[1]]

Copied to Clipboard!