After Effects Expressions

Copy-ready expressions I use every day. Click a title to expand it, then copy the code.

Checkbox Visibility Toggle

Links a text or other property to a Slider Control on a control layer.

if (thisComp.layer("Checkbox").effect("Checkbox Control")("Checkbox") == 1) {
  "Visible"
} else {
  "Hidden"
}
Uppercase Text

Automatically converts all characters in the text layer to uppercase.

text.sourceText.toUpperCase()
Count Characters

Returns the total number of characters in the text.

text.sourceText.length
Slider Value Display

Adds custom text to the name of the current composition.

var slider = thisComp.layer("Controller").effect("Slider")("Slider");
"Value: " + Math.round(slider)
Layer Index Display

Returns the index position of the layer in the timeline.

thisLayer.index
Show Current Time

Displays the current composition time up to two decimals.

time.toFixed(2)
Rounded Slider Value

Rounds the value of a slider to the nearest whole number.

Math.round(effect("Slider Control")("Slider"))
Current Frame Number

Converts the current time into a frame number.

"Frame: " + timeToFrames(time)
Add Newline Text

Appends a new line to existing text using the newline character.

value + "\nNext line"
Default If Empty Text

Shows default text if the original source is empty.

if (text.sourceText == "") "No Text" else text.sourceText
Count Words

Counts the number of words in the text layer.

text.sourceText.split(" ").length
First Character

Returns the first character of the text layer.

text.sourceText.charAt(0)
After Effects Version

Displays the current version of After Effects.

"AE v" + app.version
Slider Plus Ten

Adds 10 to the value of a slider control.

parseInt(effect("Slider")("Slider")) + 10
Comp and Layer Info

Displays both comp name and current layer index.

thisComp.name + " – Layer " + index