After Effects expression generator

Pick a preset, set it, copy the expression. Or describe your own.

Presets free, no accountCustom with AI: 20 a dayAfter Effects 2023 and later

Bounce preview: Bounces back when it lands on its last keyframe, smaller each time.0.0 s

Bounce

Bounces back when it lands on its last keyframe, smaller each time.

Paste into: Position
// Bounce: bounces back after the last keyframe.
var e = 0.6; // bounciness, 0 to 1
var g = 5000; // gravity
var nMax = 6; // bounces
var n = 0;
if (numKeys > 0) {
  n = nearestKey(time).index;
  if (key(n).time > time) n--;
}
if (n > 0) {
  var t = time - key(n).time;
  var v = mul(velocityAtTime(key(n).time - 0.001), -e);
  var vl = length(v);
  var vu = vl > 0 ? normalize(v) : mul(v, 0);
  var tCur = 0, segDur = 2 * vl / g, tNext = segDur, nb = 1;
  while (tNext < t && nb <= nMax) {
    vl *= e; segDur *= e; tCur = tNext; tNext += segDur; nb++;
  }
  if (nb <= nMax) {
    var d = t - tCur;
    add(value, mul(vu, d * (vl - g * d / 2)));
  } else {
    value;
  }
} else {
  value;
}

Needs: Two Position keyframes: the start, and where it lands.

How it works.

  1. 1

    Pick a preset.

    Or choose Custom and say what the layer should do.

  2. 2

    Set the sliders.

    The preview moves with them, so you see it before you paste.

  3. 3

    Copy the expression.

    It says which property it goes on, and what the layer needs first.

  4. 4

    Paste it in After Effects.

    Alt-click the stopwatch of that property (Option-click on a Mac) and paste.

More tools.

All tools

Questions.

Which versions of After Effects does it work in?

After Effects 2023 and later, with the JavaScript expression engine (the default).

What if the expression doesn't work?

Check it's on the property named above the code, and that the layer has what it needs (some presets need keyframes). For Custom, say it another way, or use “It didn't work? Tell us” under the result.

Who writes the expressions?

We wrote the presets. Custom uses an AI model by Anthropic, set up for After Effects expressions; your sentence is sent to it, nothing else is.

Is there a limit?

Not on the presets. Custom, with AI, is 20 a day per account, so it stays free. It resets every day at midnight UTC.

Why do I need an account?

Only for Custom, which runs an AI model; the account keeps its daily count. The presets need no account.