Skip to content

Free After Effects expressions and scripts

24 expressions and 15 scripts, each run in After Effects 2025 before it went up: loops, springs, text effects and scripts that keyframe whole animations for you. Copy the code, no account needed, or add it to Flexile and run it with one click. Updated

Recipes: Flexile and the tools together

An audiogram that thumps on every kick

Flexile’s Audio page finds every kick in the song and marks it on a null. Beat Pulse reads those marks and springs the Wave Line waveform on each hit, so the picture lands exactly on the music.

  1. Put the song in your comp. On Flexile’s Audio page select it, keep Auto and Mark each hit on, and click Create keyframes.
  2. Draw three lines with the Pen tool, select their Paths and click Wave Line.
  3. Select the three lines’ Scale and click Beat Pulse. It finds the hit markers on its own.

Also uses Beat keyframes (Audio page), all in the Flexile panel.

Add to Flexile puts a tool on the Flexile panel’s Tools page, one click to run (free account). Get code copies or downloads it, no account needed.

Loop, swing and wave expressions

Loops, swings, physics and motion on markers, for any property. Previews are rendered in After Effects from the code. Swipe for more.

Loop Keyframes

Expression

loopOut() with more modes: repeats your keyframes forever (cycle, ping-pong, offset or continue), paths included.

Select: Any property with two or more keyframes (Position, Rotation, Scale, colour, path…)

How it works

Plays the keyframed animation again and again after the last keyframe, on any property and any number of dimensions, shape paths included (After Effects has no loopOut for paths, so those repeat in cycle or pingpong mode). Switch mode to "pingpong" to play back and forth, "offset" to build on each loop or "continue" to keep the last speed; keyCount loops only the last few keyframes. Set loopBefore to true to also loop before the first keyframe.

Based on After Effects' built-in loopOut() and loopIn() expression methods

Pop In

Expression

Springs a layer up from nothing when it starts and shrinks it away at its end. No keyframes needed.

Select: Scale (or Opacity) of one or more layers

How it works

At the layer's in point the property springs from 0 to its value with a lively overshoot, and shrinks back to 0 just before the out point, so trimming the layer re-times the animation. Tune freq and decay for a softer or bouncier spring, delay to wait after the in point, and set popOut to 0 to stay on screen.

Based on the damped-spring (inertial bounce) expression family

Squash & Stretch

Expression

Adds a jelly squash-and-stretch wobble every time the layer lands or bounces on a Position keyframe.

Select: Scale of a layer with Position keyframes (e.g. a bouncing ball)

How it works

When the layer arrives at a Position keyframe with speed (a landing or a bounce, not the top of a jump or a launch), it squashes wide and stretches tall in turn, keeping its volume, and settles. Put the anchor point at the bottom (Anchor to Bottom) so it squashes against the floor. If every keyframe is eased it wobbles after each one; without Position keyframes it wobbles once at the in point. Tune amount, freq and decay.

Based on the classic volume-preserving squash-and-stretch rig

Float Hover

Expression

A gentle, seamlessly looping idle float. Every layer drifts out of step, so a group feels alive.

Select: Position of one or more layers (icons, cards, characters)

How it works

Bobs the layer up and down with a small sideways figure-eight drift that loops every period seconds, starting each layer at its own random point in the cycle so a group never moves in unison. Raise amp for a bigger bob, drift for more sway, and set period to your loop length.

Based on the sin(time) hover/bob expression

Pendulum Swing

Expression

Swings a layer like a pendulum from its anchor point and lets it settle, starting at its in point.

Select: Rotation (or X Position for a side-to-side swing)

How it works

Starts at the full angle when the layer begins and swings back and forth around the anchor point, losing a little energy each time. Put the anchor point at the pivot (Anchor to Bottom with where = "top"). Set decay to 0 for a swing that never stops; on a 2D/3D property the swing moves along X.

Based on the damped cosine pendulum expression

Wave by Index

Expression

Ripples a row of layers in a seamless sine wave, each one a little behind the layer above it.

Select: Position (or Rotation, Scale, Opacity) of several layers

How it works

Each layer moves on a sine wave whose timing is offset by its layer number, so a row of duplicates turns into a travelling wave that loops seamlessly. Change amp, freq and spread; on 2D/3D properties axis picks X (0), Y (1), Z (2) or all (-1).

Based on the Math.sin(time) oscillation with an index offset

Wave Line

Expression

Turns a shape path into a travelling sine wave. Stack a few lines for an instant audio or water wave.

Select: Path of a shape layer (draw a line with the Pen tool, twirl down to Path)

How it works

Replaces the path with a smooth wave as wide as your drawn path, at its height, and moves it along so it loops every 1/freq seconds. Several lines with the expression ripple one after another (spread). Set waves for more crests, amp for height and taper to false for a full-height wave to the ends.

Based on the createPath() sine-wave path expression

Distance Ripple

Expression

Pulses a grid of layers in rings spreading out from a centre, like a drop in water.

Select: Scale (or Opacity) of many layers, e.g. a grid of dots

How it works

Each layer grows as a ring passes it, timed by its distance from a layer named "Target" (or the comp centre), so a grid of duplicates turns into a ripple that loops every 1/freq seconds. Move the Target to move the source of the waves; change amp, wavelength and freq.

Based on the distance-from-a-point ripple expression

Spin Up & Down

Expression

A rotation expression that spins a layer up from rest, holds the speed, then eases to a stop. No keyframes.

Select: Rotation of gears, wheels, fans, loaders

How it works

Starts at rest on the layer's in point, accelerates along a smooth S-curve for rampIn seconds, spins at rpm turns per minute, and decelerates to a stop exactly at the out point. Trim the layer to re-time the whole spin; use a negative rpm to spin counter-clockwise.

Replay on Markers

Expression

Replays a property's keyframed animation at every layer marker: animate once, trigger it anywhere.

Select: A keyframed property on a layer with markers (add markers with * on the numpad)

How it works

Keyframe the animation once (a pop, a flash, a jump) and drop layer markers wherever it should play; each marker restarts it from the first keyframe, so syncing to a beat is just placing markers. Before the first marker it holds the first keyframe; set holdFirst to false to also play the original keyframes, and useCompMarkers to true to follow the comp's markers.

Based on the marker-triggered animation expression

Beat Pulse

Expression

Springs a layer on every hit Flexile's Audio page marks in your song, all at once or rippling out from a centre.

Select: Scale (or Opacity) of the layers that react, after Beat keyframes with Mark each hit on (Flexile's Audio page)

How it works

Gives the property a punch on each hit marker that springs back and settles. It reads this layer's own markers, else the ones Flexile's Audio page puts on its "Audio · <song>" null (Beat keyframes with Mark each hit on), else the comp's markers, so syncing to music needs no pick-whip. Set band to follow one band's markers ("Kick", "Snare"…) when you keyed several, and travel to send each hit out from a layer named "Target" (or the comp centre) as a ripple, in pixels per second.

Based on the "time since the last marker" expression, fed by the hits Flexile's Audio page marks

Progress Bar & Ring

Expression

Fills a progress ring, bar or slider from 0 to 100% over the layer's length, with an ease.

Select: Trim Paths End of a ring, Scale of a bar (anchor on its left edge), or any slider

How it works

Maps the layer's time to a 0 → value fill: Trim Paths End for loading rings, Scale (X only) for bars, or any 1D property such as a slider, an opacity or a value that drives other expressions. By default it fills over the whole length of the layer, so trimming re-times it; set dur for a fixed length and eased to false for a constant speed.

Follow, spring and look-at expressions

Layers that follow, lag, lean and stretch as something else moves. Previews are rendered in After Effects from the code. Swipe for more.

Follow the Leader

Expression

Copies the same property from the layer above a few frames later: instant trails and follow-the-leader.

Select: The same property on several stacked layers (e.g. Position of 8 duplicates)

How it works

Finds the same property on the layer directly above (Position, Rotation, an effect slider, a shape colour…) and plays it delay frames later. Apply it to a stack of duplicates under an animated leader and each one follows the one above, building a trail. Set keepOffset to true to keep each layer's own distance from its leader.

Based on the classic follow-the-leader valueAtTime expression (popularised by Dan Ebberts / motionscript.com)

Spring Follow

Expression

Inertia follow: chases a leader as if tied to it by a spring, overshoots, wobbles and settles. Stack several for a tail.

Select: Position of the follower layers (below an animated leader)

How it works

Follows a layer named "Target", or else the nearest layer above with Position keyframes, through a damped spring, keeping the offset you placed it at. Layers further down the stack follow more loosely, so a column of followers under one leader whips like a tail. Raise stiffness for snappier, lower damping for wobblier.

Based on the damped-spring (inertial follow) expression

Look At Target

Expression

Keeps layers pointing at a layer named "Target", or at the layer above when there is none.

Select: Rotation of the layers that should turn (arrows, eyes, turrets)

How it works

Turns the layer so its right side faces the target's anchor point, wherever either of them moves, and takes rotated parents into account. Name your target layer "Target" (or change targetName); without one, each layer looks at the layer directly above it. Use offset if your artwork points up (-90) or left (180).

Based on the 2D look-at (atan2) rotation expression

Orbit Target

Expression

Circles layers around a layer named "Target" at the distance you placed them, following it as it moves.

Select: Position of the layers that should orbit

How it works

Each layer orbits the target's anchor point on the circle it starts on, so you set the radius and starting angle just by placing it; if it starts on the target it uses a 150 px radius. Name the centre layer "Target" (or change targetName); otherwise the layer above, then the comp centre, is used. Set squash below 1 for a flat, tilted orbit and negative turns to go counter-clockwise.

Based on the circular-motion (cos/sin of time) expression

Tilt by Speed

Expression

Leans a layer into its sideways movement and lets it swing back when it stops: instant secondary motion.

Select: Rotation of layers with animated Position (anchor at the bottom to lean, at the top to dangle)

How it works

Turns horizontal speed into a lean (lean degrees at 1000 px/s, capped at maxLean) and follows it through a soft spring, so the layer tilts as it sets off and rocks back and forth when it stops. Put the anchor point at the bottom for things that stand, at the top for things that hang. Raise damping for less swing.

Stretch by Speed

Expression

Stretches a layer in the direction it moves, the faster the longer, keeping its volume. Instant smear.

Select: Scale of layers with animated Position

How it works

Reads how fast the layer moves and stretches it along that axis (wider when moving sideways, taller when moving up or down) while squeezing the other axis to keep the volume, then relaxes when it stops. amount sets the stretch at 1000 px/s and limit caps it. Diagonal moves stretch less; pair it with Tilt by Speed for more life.

Based on the velocity-driven squash-and-stretch expression

Text expressions: counter, typewriter, countdown

Source Text expressions: counters, timers, typing and decoding. Previews are rendered in After Effects from the code. Swipe for more.

Number Counter

Expression

Counts up to the number you typed, keeping commas, decimals and symbols ($12,500, 98.6%, 1.250,00 €).

Select: Source Text of a text layer that contains a number

How it works

Type the final value in the text layer, apply, and it counts up from 0 over 2 seconds with an ease, keeping the text around the number (the longest one, if there are several), the decimals and the thousands separator you typed. Change from, dur and delay to re-time it. Rule for "1,250" vs "1,25": a lone separator followed by exactly three digits is read as thousands.

Based on the number-counter Source Text expression with thousands separators

Typewriter

Expression

Typewriter text effect: types the layer's text letter by letter with a blinking cursor; edit the text any time.

Select: Source Text of a text layer

How it works

Reveals the text you typed at a steady speed from the layer's in point, with a cursor that stays solid while typing and blinks while it waits. Set erase to delete the text again before the out point, cursor to "" to hide it, and perSecond for the typing speed. Left-justified text keeps letters from shifting as they appear.

Based on the substr() typewriter Source Text expression

Countdown Timer

Expression

Counts down from the time you typed (05:00, 1:30:00 or 10) to zero in mm:ss, in real time.

Select: Source Text of a text layer containing a time like 05:00

How it works

Type the starting time in the layer in any of the forms 10, 0:45, 05:00 or 1:30:00 and it ticks down second by second from the in point, keeping your format, leading zeros and any words around it. Set countUp to true to count up to the typed time instead, and pace to run faster than real time. A monospaced font stops the digits from jittering.

Based on the minutes:seconds countdown Source Text expression

Scramble Decode

Expression

Text scramble decoder: random characters lock into your text from left to right.

Select: Source Text of a text layer

How it works

Starts as random letters and digits that flicker, then resolves into the real text from left to right over dur seconds, keeping spaces, line breaks and lower case. Change glyphs for other random characters and rate for how often they change. Use a monospaced font so the line width stays still.

Based on the seedRandom text-scramble expression

Rotating Words

Expression

Cycles through words one at a time: type "fast|simple|yours" and each gets its moment.

Select: Source Text of a text layer with words separated by | or line breaks

How it works

Splits the layer's text at | or line breaks and shows one part at a time, each for hold seconds, looping forever from the in point. Set typeOn to type each word in letter by letter. Pair it with a static text layer ("Make it") for rotating headlines.

Animation scripts that keyframe for you

Scripts that keyframe the animation for you, eased and editable, across every selected layer. Previews are rendered in After Effects from the code. Swipe for more.

Stagger In

Script

Staggers the selected layers in one after another: they rise, fade and grow into place with a smooth ease.

Select: The layers to bring in (top of the timeline goes first)

How it works

Adds eased Position, Opacity and Scale keyframes from the current time, staggered down the timeline, ending exactly where each layer sits now, so the end state is your layout. Change from for the direction, distance, dur, stagger and startScale. Works best on layers without keyframes on those properties.

Slide In

Script

Slides the selected layers in from outside the comp, each from its nearest edge, gliding to a stop.

Select: The layers to slide in (top of the timeline goes first)

How it works

Measures each layer and keyframes it from just outside the comp edge closest to it (or from one side) to where it sits now, staggered from the current time, with a quick start and a long, smooth glide. Set slideOut to true to also send each layer back out before its out point.

Swing In

Script

Swings the selected layers into place like hanging signs: overshoot, swing back and settle.

Select: The layers to swing in (top of the timeline goes first)

How it works

Moves each anchor point to the top centre without moving the layer (hinge), then keyframes Rotation from angle through smaller and smaller overshoots to its current rotation, eased at every turn, plus a quick fade in, staggered from the current time. Set hinge to false to swing around the anchor point you have; use a positive angle to swing in from the other side.

Trim Paths Draw On

Script

Draws the strokes of the selected shape layers on with Trim Paths, one after another, with a smooth ease.

Select: One or more shape layers with strokes (icons, lines, logos)

How it works

Adds Trim Paths at the top of each shape layer's Contents (or reuses one) and keyframes End from 0 to 100% with an ease, staggered down the timeline from the current time. Set erase to also wipe the lines away before each layer's out point. Fills are trimmed too, so it suits outlined artwork best.

Confetti Burst

Script

Bursts confetti out of the selected layer at the playhead: real keyframed pieces that pop, hang and fall.

Select: The layer the confetti should burst from (a button, a logo, a number)

How it works

Creates count small shape layers at the layer's position at the current time, each flying out on an eased arc, hanging for a moment, then falling with gravity and shrinking away, spinning as it goes. They land in one precomp named "Confetti" (set tidy to false to keep them in the comp). Edit colors to your palette; every piece is ordinary, editable keyframes.

Motion Trail

Script

Adds a trail of fading, shrinking copies behind each selected animated layer, each a few frames later.

Select: One or more animated layers

How it works

Duplicates each selected layer copies times below itself, delays every copy by gap frames, and fades and shrinks them along the trail, so any moving layer gets a smooth echo without plugins or precomps. The copies keep all keyframes and expressions, so changing the original's animation is a matter of re-running it.

Impact Camera Shake

Script

Hits the selected layers with a hard, decaying shake at every marker, as real keyframes you can edit.

Select: The layers to shake (select a null that everything is parented to, to shake the whole scene)

How it works

At each of the layer's markers (or the comp's markers, or the current time when there are none) it keyframes a burst of eased jolts in random directions that die down over dur seconds, on Position and a little on Rotation, on top of any animation already there. Turn strength, turn, dur and hits up or down.

Parallax Camera

Script

Spreads the selected layers in depth, keeping your framing, and adds a slow eased camera push.

Select: Two or more layers, front (top of the timeline) to back

How it works

Makes the layers 3D and moves each one further back the lower it sits in the timeline, scaling and spacing it so the first frame looks exactly as before. Then it adds a one-node camera with an eased push in and sideways drift from the current time to the end of the work area, so near layers slide past far ones. Tune depth, push and drift.

Layout, timeline and cleanup scripts

Quick jobs that move nothing on screen: layout, timing and cleanup, 8 of them.

Layout

Place, stack and distribute layers.

BeforeIllustrationAfter

Grid Layout

Script

Arranges the selected layers in a tidy, centred grid by their real sizes, in timeline order.

Select: Two or more layers

How it works

Measures every selected layer (text, shapes, footage) and lays them out left to right, top to bottom in timeline order, each centred in an equal cell, with the grid centred in the comp and a short last row centred too. Animated layers keep their keyframes, offset together. Set columns for a fixed count and gap for the spacing; layers with a parent are placed in their parent's space.

BeforeIllustrationAfter

Stack Vertically

Script

Stacks the selected layers under each other by their real heights with an even gap, like a list.

Select: Two or more layers (the top one in the timeline stays put)

How it works

Keeps the top selected layer where it is and stacks the others below it in timeline order, measuring each layer's real size (text, shapes, footage, scale and rotation included). Left edges line up with the top layer by default; set align to "center", "right" or "none", and gap for the spacing. Position keyframes move along.

BeforeIllustrationAfter

Anchor to Bottom

Script

Moves the anchor point to the bottom centre of each selected layer without moving the layer.

Select: One or more layers (text, shapes, footage)

How it works

Puts the anchor point at the bottom centre of each layer's content and shifts Position (keyframes included) so nothing jumps, ready for bars that grow up, squash-and-stretch and characters that stand on a floor. Change where to "top", "left", "right", "center" or a corner such as "bottom-left". It measures size, scale and rotation at the current time.

Timeline

Sequence, trim and stretch layers.

BeforeLogo l…TitleBGIllustrationAfterLogo l…TitleBG

Loop Precomp

Script

Loops precomps and videos seamlessly to the end of the comp. Turns on time remap and adds the loop.

Select: One or more precomp or video layers

How it works

Enables Time Remap on each selected precomp or video, adds a loop expression and extends the layer to the end of the comp, so a two-second cycle fills the whole timeline. If you already retimed it with Time Remap keyframes, those keyframes are looped instead. Set toEnd to false to keep the layer's length.

BeforeIcon 1Icon 2Icon 3Icon 4Icon 5IllustrationAfterIcon 1Icon 2Icon 3Icon 4Icon 5

Random Start Times

Script

Gives each selected layer a random start within a one-second window, snapped to whole frames.

Select: Two or more layers

How it works

Moves each selected layer (with its keyframes) so it starts at a random frame between the earliest one and spread seconds later; run it again for a new shuffle, as it doesn't pile up. Great for confetti, icons and particles that shouldn't all pop at once. Change spread for a wider or tighter window.

Cleanup

Rename, precompose and tidy a comp.

BeforeTitleselectedLogoselectedPhoto.jpgselectedBGIllustrationAfterTitleLogoPhoto.jpgBG

Precompose Each

Script

Precomposes each selected layer separately, into its own comp named after it and trimmed to its length.

Select: One or more layers

How it works

Does what Layer > Pre-compose can only do for one layer at a time: each selected layer moves, with its effects and transforms, into a new comp named after it, keeps its label colour, and stays exactly where it was on the timeline. Each new comp is trimmed to its layer's length; set trim to false to keep the full comp length.

BeforeTitleOld titleCon…used by expr.Shape Layer 3BGIllustrationAfterTitleCont…kept: in useBG

Delete Hidden Layers

Script

Deletes the layers whose eye is off, but keeps hidden ones still used as parents, mattes or in expressions.

Select: Nothing: it cleans the active comp

How it works

Removes every layer in the active comp whose video switch (the eye) is off, unless it still does a job: a parent of another layer, a track matte, a layer named in an expression in this comp, or a layer you can still hear. Locked layers are left alone; set keepAudio to false to also delete hidden layers with audio. One undo brings them all back.

BeforeIcon…250% · 15 pxSmal…60% · 3.6 pxArrow150% · 9 pxIllustrationAfterIcon …250% · 6 pxSmall …60% · 6 pxArrow150% · 6 px

Keep Stroke Width

Expression

Keeps a shape's stroke the same thickness on screen however much the layer or its parents scale.

Select: Stroke Width of a shape layer's stroke (twirl down Contents > … > Stroke)

How it works

Divides the stroke width by how much the layer is scaled on screen, including parents and uneven X/Y scale, so outlines stay crisp and even while you scale icons and rings. It measures the layer's own transform; a scale inside the shape group's Transform is not compensated.

Based on the "maintain stroke width" toComp expression

How to add an expression or run a script

Add it to Flexile

  1. Click Add to Flexile on a tool. Signed in, it is saved to your account with your Cloud Tools; signed out, you sign in first (it’s free) and come back to it.

  2. In After Effects, open Flexile’s Tools page and click Refresh next to Cloud Tools. The tool is there on every computer you sign in on.

  3. Select what the tool asks for and click it. An expression goes onto every selected property; a script runs on the selection as one undo step.

Or copy the code

Every tool also works without Flexile. Open Get code on a tool to copy it.

Expression
Alt-click (Windows) or Option-click (macOS) the property’s stopwatch, paste, and click outside the field.
Script
Download the .jsx, select the layers, then choose File › Scripts › Run Script File.

Already in Flexile: 12 built-in tools

Every Flexile panel has them under Local Tools, so there is nothing to add. Rigs come with sliders you tune in Effect Controls. The expressions behind Bounce and Overshoot are explained in bounce and overshoot expressions.
  • Overshoot

    Expression

    An inertial overshoot after each keyframe, tuned with Amplitude, Frequency and Decay sliders.

    Select: Keyframed properties

  • Bounce

    Expression

    Bounces off the last keyframe with Elasticity, Gravity and a bounce count.

    Select: Keyframed properties

  • Flicker

    Expression

    A seeded, looping flicker between a minimum and a maximum.

    Select: Opacity or any property

  • Wiggle

    Expression

    A wiggle that loops seamlessly, with seed, frequency and magnitude sliders.

    Select: Any property

  • Null & Parent

    Script

    Adds a null at the centre of the selection and parents the layers to it.

    Select: One or more layers

  • Text Box

    Script

    A rounded box behind each text layer that resizes with the text.

    Select: Text layers

  • Quick Connector

    Script

    Lines between layers that follow them: web, line, closed or from the centre.

    Select: Two or more layers

  • Move on Timeline

    Script

    Staggers the layers’ start times by a number of frames or seconds.

    Select: Two or more layers

  • Align Center

    Script

    Lines the layers up on a shared horizontal centre; Position keyframes move with them.

    Select: Two or more layers

  • Align Left

    Script

    Aligns the layers’ left edges to the leftmost one.

    Select: Two or more layers

  • Align Right

    Script

    Aligns the layers’ right edges to the rightmost one.

    Select: Two or more layers

  • Invert Layer Order

    Script

    Reverses the stacking order of the selected layers.

    Select: Two or more layers

Questions about these expressions and scripts

Do I need Flexile to use these tools?
No. Every expression and script works in After Effects on its own: open Get code on a tool, copy it, and follow the steps under it. Flexile makes them one click: added tools sit on the panel’s Tools page, on every computer you sign in on. Read how to install Flexile.
Are they free?
Yes. The tools are free, and Flexile is free during the beta with a Flexile account.
Can I use them in client work?
Yes. Use them, and change them, in personal and commercial projects. A tool that is part of your project file needs no credit.
Which versions of After Effects do they work in?
They were tested in After Effects 2025. The expressions work in both the JavaScript and the Legacy ExtendScript expression engines. Flexile itself needs After Effects 2025 or newer on macOS or Windows.
Where does Add to Flexile put a tool?
In your Cloud Tools, saved to your Flexile account. In the panel, click Refresh next to Cloud Tools and it shows up with its type icon. Edit, favourite or delete it there like one of your own tools; adding it again does not make a copy.
Can I change how a tool behaves?
Yes. The numbers at the top of each tool are its settings, explained under Get code. In Flexile, click the pencil next to the tool, change them, try it with Test and save.
Is it safe to run a script from here?
A script runs with the same access as any After Effects script. Each one here only changes the open project, runs as one undo step and was tested before it was published. Read the code under Get code before you run a script, from here or anywhere else.
Can my AI assistant use these tools?
Yes. Flexile’s MCP server lets Claude, ChatGPT desktop or Cursor list, run and edit your Cloud Tools, the ones added from here included, and write new ones. The AI setup guide connects it.