Skip to main content
An expression makes a value follow something else on every frame: a dot riding the tip of a line as it draws, a badge pinned to a card that resizes, a number counting up, a shape that drifts or pulses without keys. It is written as text in JavaScript expression syntax, with the helpers After Effects expressions have, and stored as the values the renderer evaluates, so it renders the same in the editor and in every export. Agents get this page as get_motion_schema with schema: "expressions" (REST: GET /v1/motion/schema?schema=expressions).

Where an expression goes

  • bindProperty {node, property, to} binds a numeric property (x, y, rotation, scale, opacity, a field:…) or a title’s text to an expression, in the units commands take.
  • setCurve {name, value} names an expression (or keys, or a number) every node of the canvas reads as curve(name): one value for many fields.
  • In an op (node.patch, node.insert), {expression: text} stands wherever a stored number or vector goes, as {seconds: n} stands for ticks.
  • An expression is the whole value of its field and gives what the field holds: one number for a property (take .x or .y of a point), a vector where the field is one.
  • A bound x or y is added to where the node is drawn, so what follows a point is drawn around 0,0. scale and rotation turn around the node’s anchor, the centre of what it draws unless anchorX and anchorY say otherwise: a scale needs no x or y to hold the node in place.
  • A wrong expression changes nothing: the error says where the text stopped and what to write, and the room checks that every node, curve and width it reads exists before anything is stored.

Syntax

  • An expression is JavaScript expression syntax for one value: a number, a vector of 2 to 16 numbers, a list or a path. It is converted to the tree of values the document stores, never run, so it reads back field by field and renders the same everywhere.
  • Numbers are 2, .5, 1e3; true and false are 1 and 0; a vector is [x, y], and a colour is [r, g, b, a] with each channel 0 to 1.
  • + - * /, **, == != < <= > >= (and ===, !==), !, a leading - and c ? a : b bind as in JavaScript. A comparison gives 1 or 0, and c ? a : b evaluates only the branch it takes.
  • + - * / work on vectors component by component, and a number applies to every component: [1, 2] * 2 is [2, 4].
  • v.x, v.y, v.z, v.w and v[n] read one component of a vector, and .left, .top, .width, .height the same four of a box, as After Effects names a rectangle’s. A place that takes one number (a position’s x, an opacity) needs one: pointOnPath(p, t).x.
  • Everything else is a function call. Strings, in either kind of quotes, name nodes, curves, clocks and modes.
  • Name a value with const name = value; on a line before the last, whose value is the expression’s, as After Effects reads an expression. (() => { const a = 1; return a * 2; })() names values anywhere a value goes. A name is set once.
  • Math.PI, Math.E, Math.LN2, Math.LN10, Math.LOG2E, Math.LOG10E, Math.SQRT2, Math.SQRT1_2, and Math.abs, acos, asin, atan, atan2, ceil, cos, exp, floor, fround, log, max, min, pow, round, sign, sin, sqrt, tan, trunc give what JavaScript gives.
  • // ... and /* ... */ are comments.

Units

  • Time is seconds, as in After Effects: time and every clock, every time a function takes (valueAtTime, timeShift, ref, toComp, nodePath, sampleImage) and every time one gives (inPoint, outPoint, marker, keyTime). A time lands on the frame it falls in.
  • Rotations are degrees; sin, cos, tan and atan2 work in radians, as in JavaScript. degreesToRadians and radiansToDegrees convert.
  • Lengths and positions are px. A node’s local space starts at the top-left of its layout box, before its transform.
  • Opacity, scale, a trim’s start and end, and a point on a path are fractions: 0.5 is half.
  • A colour is [r, g, b, a], each from 0 to 1.

Recipes

Every recipe runs in Tella’s test suite as shown.

Ride the tip of a line as it draws

One curve is the progress: the line’s trim and the dot both read it, so they cannot drift apart whatever the easing or the path’s shape. nodePath is the line’s whole path, before its trim, in the line’s own space; toComp(point, "route") takes a point of it to where the line shows, so the dot stays on it when the line is moved, scaled or animated. A binding to x and y is added to where the shape is drawn: draw the rider around 0,0 (a 24 px dot has the box -12, -12, 24, 24). The rotation line turns an arrow or a vehicle along the path. On a document that holds:
send:

A second rider a beat behind the first

valueAtTime reads any value at another time, in seconds, so a trail is the same expression read a little earlier. On a document that holds:
send:

Pin a badge to the corner of a node that moves or resizes

nodeBox measures what another node draws on this frame as a box with .left, .top, .width and .height, here its painted box on the canvas ("composition"), so the badge follows the card through its animation, its scale and its text reflowing. On a document that holds:
send:

Count a number up in a title

Bound to a title’s text, the title shows the number. linear(t, tMin, tMax, value1, value2) maps the clock onto the count and holds at both ends. On a document that holds:
send:

Pulse and drift without keys

A sine of the clock loops forever; wiggle(value, frequency, amplitude) drifts around a value, here 12 px either side of where the shape is drawn, twice a second. On a document that holds:
send:

An expression in any field, with an op

bindProperty covers the properties commands name. Anywhere else a stored value goes (any field inspect_motion_node shows as a number), an op takes {expression: text} and stores what it reads as. Here a shape fades in over its first half second with no keys. On a document that holds:
send:

What an expression reads

Helpers

After Effects’ expression helpers, and a few of Motion’s own. Each stands for stored values, which is how the document view prints it back.

Operators

The functions the document stores. + - * /, comparisons and c ? a : b are shorthands for theirs.

Limits

  • The canvas’s own nodes read each other through what is drawn (nodePath, nodeBox, toComp) and through curves. A node’s path and its local points are in its own space: toComp(point, node) gives where they show. ref, marker, index(), numLayers(), inPoint() and outPoint() read within a composition (a template’s nodes) and between the canvas’s own nodes. A document whose writer cannot store a read between canvas nodes yet refuses it naming the schema version: there, keep the shared value in a curve and read curve(name) from both.
  • A curve cannot hold a measurement (nodePath, nodeBox, toComp): measure in the property that needs it, and keep the progress, not the point, in the curve.
  • A measurement is read after layout, so what layout depends on cannot read one: a title’s text, a node’s visibility, a prop. A title cannot show nodePathLength or a box’s width; x, y, rotation, scale, opacity, effect parameters and shader uniforms can read them.
  • view_motion_document shows every expression in this form, so what you wrote reads back as you wrote it, commands included.

Differences from JavaScript and After Effects

The language keeps JavaScript’s syntax and After Effects’ names wherever they mean the same thing. Where it differs, this is why:
Last modified on November 23, 2026