Skip to content
Motion Graphics & Animation

How to Get Trim Paths and Line Animation Right

Learn to diagnose and fix common trim paths and line animation faults, from wrong-way draws and uneven strokes to slow timing and SVG mismatches.

MediaScaleUp Editorial Team 31 min read 19 views
How to Get Trim Paths and Line Animation Right

Trim paths and line animation are the techniques that make a stroke appear to draw itself: an icon sketches its own outline, a signature writes across the screen, a diagram connects its boxes one arrow at a time, a route line travels across a map. In After Effects the job is usually done with Trim Paths, a shape-layer operator that reveals a stroke over time. On the web the same effect is built from two SVG properties, stroke-dasharray and stroke-dashoffset, that turn a path into a single long dash and then slide it into view. The look is the same. The mechanics, and the ways it goes wrong, are different.

This matters to anyone whose motion work has to explain something. A drawn line points the eye. It shows order, direction and connection in a way a cut or a fade can't. That makes it a staple of explainers, onboarding sequences, product UI demos, data stories and brand marks. It is also cheap to build and light to deliver in both video and browser formats, which is why teams reach for it so often, and why so many of those animations have the same small, fixable faults: lines drawing backward, strokes that change thickness halfway through, draws that plod along, and paths so dense with points that they stutter.

This article is a troubleshooting manual. It is organized by symptom. For each common problem you will find how to recognize it, what usually causes it, how to fix it in After Effects and in SVG, and how to stop it from happening on the next project. A worked example and a prevention checklist follow the symptom sections.

How Trim Paths and SVG Line Drawing Actually Work

Almost every fix in this manual comes from understanding the mechanism, so it is worth five minutes before looking at symptoms.

Trim Paths in After Effects

Trim Paths is an operator you add to a shape layer's contents. It has three core properties. Start and End are percentages along the path: the visible stroke is the part between them. Offset is measured in degrees and slides the visible segment around the path, so a full 360 degrees moves it one complete length. A fourth setting, Trim Multiple Shapes, decides whether every path in the group is trimmed Simultaneously (each path draws its own full length over the same time) or Individually (the paths are treated as one continuous sequence, in stacking order). Adobe documents these controls in the After Effects User Guide on the Adobe Help Center, and that reference is worth keeping open while you work through the fixes below.

Two rules about Trim Paths explain a large share of the problems people run into. First, operators in a shape group act on the paths above them in the same group. Put Trim Paths below a path and it trims that path. Put it inside a different group and it does nothing to the path you meant. Second, Trim Paths follows the path's own direction. It does not care what the line looks like. It only cares where the first vertex is and which way the path runs from there.

stroke-dasharray and stroke-dashoffset in SVG

SVG has no trim operator. Instead, you exploit dashing. Set stroke-dasharray to the length of the path, and the stroke becomes one dash as long as the path followed by a gap just as long. Set stroke-dashoffset to that same length, and the dash pattern is pushed so that the gap covers the whole visible path. Animate stroke-dashoffset down to zero and the dash slides into place, so the line appears to draw from the path's start point. The MDN Web Docs reference for stroke-dashoffset covers the property's syntax and browser behavior in detail.

You need the path length to do this. There are two common ways to get it. You can measure it in JavaScript with the path element's getTotalLength() method and write the value into the styles. Or you can set a pathLength attribute on the path, for example pathLength="1", which tells the browser to treat the path as one unit long for dash calculations, so a dasharray and dashoffset of 1 work regardless of the true length. Both approaches depend on the same thing Trim Paths depends on: the path's start point and direction.

Where the two methods differ

Trim Paths is non-destructive and parametric. You can trim from both ends, loop with Offset, and sequence many paths from one operator. SVG dashing is simpler and more literal. It works one path at a time, relies on an accurate length, and interacts with any real dash pattern you already have on the stroke. If a line animation has to ship in both formats, you are really building it twice, and the source artwork has to satisfy the stricter of the two sets of rules.

Symptom Index: Diagnosing Line Animation Faults Fast

Use this table to jump to the likely cause. Most faults trace back to one of a few issues: path direction, stroke scaling, timing, stacking order or path complexity. The sections that follow give the full diagnosis and fix for each.

SymptomMost likely causeFirst fix to try
Line draws from the wrong endPath direction runs opposite to the intended drawReverse path direction, or swap which property animates (Start vs. End)
Closed shape starts drawing at an odd spotFirst vertex sits in the wrong placeSet First Vertex in After Effects, or reorder the path data before export
Some strokes look thicker than othersLayers or groups scaled after the stroke was setReset scale to 100% and resize the path, not the layer
Draw feels robotic or sluggishLinear keyframes, overlong durationApply ease, shorten the draw, check it at full speed
All lines fire at once or in a jumbled orderTrim Multiple Shapes setting or stacking orderSwitch to Individually, or offset separate trims in time
Dot or blip visible before the line startsRound caps on a zero-length segmentHide the stroke until the draw begins, or overshoot the offset
Line stutters, wobbles or renders slowlyToo many anchor points, often from auto-tracingSimplify the path and rebuild with fewer, cleaner points
SVG draws differently from the video versionDifferent path direction or length after export and optimizationCheck exported path data; measure length after optimization

When a fault is unfamiliar, work through the causes in the order the table lists them. Direction and scale problems are the most common and the quickest to rule out. Path complexity is the slowest to fix, so check it last unless the symptom points straight at it.

The Line Draws from the Wrong End or the Wrong Starting Point

How to recognize it

The arrow draws from its head back to its tail. The signature writes itself right to left. The circle around a key figure starts at three o'clock when the design called for twelve. In a set of icons, half draw clockwise and half counterclockwise, so the set feels mismatched even though each icon looks fine on its own.

Likely causes

Every path has a direction. It is set by the order in which the points were drawn or generated, and it is invisible in a still frame. An illustrator who drew an arrow tail-first gets a path that draws tail-first. One who drew it head-first gets the reverse, and both look identical in the design file. Closed shapes add a second variable: the first vertex. A circle has no natural start, so the software picks one. For parametric ellipses in After Effects and for many exported circles, that point is often on the right-hand side or the top, depending on how the shape was made.

Direction also changes silently in the pipeline. Reflecting a path in Illustrator reverses it visually. Joining two open paths can flip one of them. Some export and optimization steps rewrite path data. If direction was never checked, any one of these steps can put the start point somewhere unexpected.

The fix in After Effects

Start by checking which property you animated. Keyframing End from 0% to 100% draws from the path's start. Keyframing Start from 100% to 0% draws from the path's end. For a single open path, switching which property you animate is often the fastest fix. For a path you want to leave keyframed as it is, reverse the path itself. Parametric shapes such as rectangles, ellipses and polystars have a path direction setting, and Bezier paths in current versions have a toggle to reverse path direction in the timeline. For closed Bezier paths, select the vertex you want to start from and use Set First Vertex from the Layer menu's mask and shape path commands. For a parametric ellipse or rectangle, rotating the shape or using Offset on Trim Paths moves the starting point without touching the geometry. A quarter turn is 90 degrees of Offset.

The fix in SVG

In SVG the draw always begins at the path's first point, so the fix is in the path data. In Illustrator, reversing path direction or redrawing the path in the intended order before export is the cleanest route. For a closed shape, cut the path at the point where the draw should begin, or rebuild the circle as a path whose first command starts at twelve o'clock. If you cannot change the source, you can mirror the effect by animating stroke-dashoffset from a negative value to zero rather than a positive one, which makes the dash enter from the other end. That trick has limits with round caps and pathLength, so fixing the geometry is more reliable.

Quick fix: Before animating anything, add a temporary Trim Paths with End at 20% to every path. You will see at a glance where each line starts and which way it runs. Fix direction first, then delete the test operator and animate for real.

Preventing it

Agree on direction conventions at the design stage and write them into the handoff: arrows draw tail to head, text-like strokes draw left to right and top to bottom, circles start at twelve o'clock and run clockwise unless the story says otherwise. Ask designers to draw paths in the order they should animate, and to avoid reflecting or joining paths without checking direction afterward. When source files come from a client, budget time to audit direction rather than assuming it.

Stroke Weights Look Uneven or Change During the Move

How to recognize it

Two icons that should share a 2-pixel line look different side by side. A diagram's connector lines are visibly thinner than the box outlines. Worse, a stroke visibly thickens or thins as the layer scales up during an entrance, so the drawing effect seems to swell. On the web, lines look right on a desktop monitor and hairline-thin on a phone, or heavy on a large display.

Likely causes

Stroke width scales with the layer and group transforms above it. In After Effects, a shape layer scaled to 50% renders its 4-pixel stroke at 2 pixels, and a group inside it scaled to 150% multiplies that again. Artwork imported from Illustrator often arrives with a mix of scales because each element was resized separately. In Illustrator itself, resizing artwork with the Scale Strokes and Effects preference on changes stroke weights along with the geometry, so an icon set built at different sizes and normalized later can end up with a spread of weights. In SVG, the stroke width is in user units, so it scales with the viewBox and any transform on the element or its parents.

A second cause is aliasing. Thin strokes, especially at 1 pixel, render inconsistently when they fall between pixels, and video compression softens them further. A line that looks uneven may actually be even in weight but unevenly anti-aliased.

The fix

In After Effects, set layer and group scale back to 100% wherever you can and size the path itself, either by editing the path or by changing the Size property of a parametric shape. Where a scale animation is part of the design and the stroke must stay constant, compensate with an expression on Stroke Width that divides the intended width by the layer's scale factor, for example the target width divided by the transform scale's first value over 100. Apply that consistently, not just on the layer that happened to look wrong.

In SVG, the vector-effect property with the value non-scaling-stroke keeps a stroke's rendered width constant regardless of transforms. Be careful, though: it also changes how dash lengths relate to the path in some cases, so test the draw-on after adding it. The simpler fix is to build all icons on the same viewBox size, with the same stroke width, and scale the whole SVG element with CSS rather than transforming paths inside it.

For aliasing, choose weights that survive the delivery size. For video at 1920 by 1080, strokes of 2 pixels or more hold up far better than 1-pixel hairlines through compression. Check at 100% view, not zoomed in, and check an encoded file rather than the composition preview.

Quick fix: Select all shape layers, check the Scale column in the timeline, and sort out anything not at 100% before touching stroke widths. Most uneven-weight problems disappear once scale is normalized, and changing stroke widths first just hides the real cause.

Preventing it

Keep strokes consistent in weight by defining the stroke system at the start: one or two approved widths, a fixed artboard or viewBox size, and a rule that artwork is resized by editing geometry, not by scaling containers. Put the stroke widths in the style guide alongside colors, so designers, animators and developers all work from the same number.

The Draw Feels Mechanical, or Takes Far Too Long

How to recognize it

The line moves at one constant speed from start to finish, then stops dead. Or it moves so slowly that the viewer has understood the shape long before it is finished and is now waiting. In a UI demo or an e-learning module, a slow draw makes the whole piece feel sluggish, and viewers start scrubbing ahead.

Likely causes

Linear keyframes are the default in After Effects, and many web animations fall back on a linear timing function, which produces constant speed. Real hands and real objects accelerate and decelerate, so constant speed reads as mechanical. Duration problems usually come from setting the timing against the length of the path instead of against the viewer's attention. A long route line animated at the same speed as a short icon stroke takes several times as long, even when the message is equally simple.

There is also a less obvious cause: trim percentage is not the same as visible speed. Trim Paths moves at a constant rate along the path's length, but a path with a long straight run and a tight curl will seem to rush through the straight and crawl through the detail, or the reverse, depending on how your eye tracks it.

The fix

Use easing so lines accelerate naturally. In After Effects, apply Easy Ease to the End keyframes and then open the Graph Editor to shape the speed curve. A common starting shape for a line that draws on is a quick acceleration and a longer, softer deceleration into the end, because the eye wants to see where the line lands. In CSS, replace linear with a cubic-bezier timing function that does the same thing. Avoid ease-in-only curves on draw-ons. They make the line seem to fling off the end of its path.

Then cut the duration. As a working range, not a rule, single icon strokes tend to feel right somewhere around a third of a second to a second, and longer diagram or route lines somewhere between one and three seconds, depending on how much the viewer needs to read along the way. The right test is simple: play it at full speed, with the voiceover or UI context if there is one, and ask whether you ever wait for the line. If you do, it is too long.

For paths that mix straight runs and dense detail, split the draw. Either break the path into two segments with separate timing or add intermediate keyframes on End so the detailed section gets more time and the straight run less. The goal is even perceived speed, not even speed along the path.

Watch out: Drawing effects that take too long are among the most common reasons a line animation feels amateur. A client review of a single composition in isolation will often approve a slow draw that feels painfully slow once it sits in the finished sequence. Always review line timing in context.

Preventing it

Set a timing scale at the start of a project: a short, medium and long draw duration and one or two standard easing curves, saved as presets or animation tokens. Reuse them across the piece so the draws feel related. For pieces with voiceover, time lines to the words that explain them rather than to the length of the stroke. Our guide to reviewing animation with clients covers how to get timing feedback on the finished sequence rather than on isolated shots.

Multiple Lines Fire at Once, or in a Muddled Order

How to recognize it

Every line in a diagram starts and finishes together, so the structure the animation was meant to reveal appears all at once. Or the lines draw in sequence, but in the wrong sequence: the second arrow before the first, the outline before the detail, the label's underline before the label.

Likely causes

In After Effects, a single Trim Paths set to Trim Multiple Shapes: Simultaneously draws every path in its group over the same span. That is sometimes what you want and often not. Switch to Individually and the paths draw one after another, but in stacking order within the group, which rarely matches the story order. In SVG, a single animation class applied to every path fires them all at once unless each gets its own delay.

The fix

Stagger multiple lines for rhythm. There are three workable approaches in After Effects. The first is to reorder the paths in the group so stacking order matches draw order, then use Individually. It is quick, but it gives you no control over the gap between lines. The second is to split paths into separate groups or layers, each with its own Trim Paths, and offset the keyframes in time. It is more work but fully controllable. The third, for large sets, is to link each trim to a master slider with an expression that adds a delay based on the layer or group index, so changing one number re-times the whole set.

In SVG, assign each path an animation-delay, or set a CSS custom property per path and calculate the delay from it. Keep the stagger consistent: equal gaps create rhythm, and random gaps look like mistakes. Overlap usually reads better than strict sequence. A new line that starts when the previous one is roughly two-thirds done keeps the eye moving without making the viewer wait.

Preventing it

Write the draw order into the storyboard or animatic, not just the design. Name paths and groups by their role and order, such as 01-arrow-input and 02-arrow-output, so stacking order and draw order match from the start. This matters most in explanatory work such as scientific data animation, where the order in which lines appear is part of the argument.

Ends Look Wrong: Caps, Dots, Gaps and Joins

How to recognize it

A small dot sits on screen before the line starts to draw. The leading edge of the line looks blunt and chopped when the design is soft and rounded. A closed shape finishes with a visible notch or overlap where the start and end meet. Sharp corners flash spikes as the line passes through them.

Likely causes

Stroke caps affect how line ends look, and during a draw-on the leading end is on screen the whole time. After Effects offers Butt, Round and Projecting caps. SVG offers butt, round and square. A butt cap ends flush with the path, which gives a crisp, mechanical leading edge. A round cap adds a semicircle beyond the end, which reads as a pen or marker. A projecting or square cap extends past the end by half the stroke width.

Caps that extend past the path end are also the usual source of the stray dot. When the visible length is zero or close to it, a round or square cap can still render as a small dot or square at the start point, in some renderers and some browsers. Closed-shape notches come from the same geometry: with round caps, the two ends of the stroke overlap slightly where they meet, and with butt caps on a path whose start and end don't join cleanly, a tiny gap can show.

Corner spikes come from line joins. A miter join on a sharp angle extends into a long point. As the trim passes through, that spike appears suddenly. The miter limit controls when a miter falls back to a bevel.

The fix

Choose caps to match the design language, and match them across every line in the piece. Round caps suit hand-drawn, friendly and signature-style work. Butt caps suit technical diagrams and UI. To remove the starting dot, keep the stroke hidden until the draw begins, for example by setting stroke opacity to zero on the first frame, or by starting the animation a fraction beyond the path length. In SVG, a dasharray a little longer than the path length plus the cap width, with a matching offset, keeps the cap fully inside the gap. For closed shapes, use a closed path rather than an open one whose ends happen to touch, and let the end of the draw land on the join. For corner spikes, use round or bevel joins, or lower the miter limit.

Preventing it

Specify caps and joins in the stroke system, next to widths. Preview the first and last frames of every draw at full resolution. Those are exactly where cap artifacts hide, and they are easy to miss while scrubbing.

Paths Stutter, Wobble or Render Slowly

How to recognize it

The leading edge of the line speeds up and slows down for no visible reason. The line wobbles slightly as it draws, or tiny kinks appear in what should be smooth curves. After Effects previews slow down on a shape layer that looks simple. On the web, the SVG file is much larger than it should be and the animation drops frames on lower-powered phones.

Likely causes

Complex paths with unnecessary points are the usual culprit. Auto-traced artwork, Image Trace output, scanned signatures and paths converted from brush strokes often contain hundreds of anchor points where a dozen would do. Each small segment is slightly different in length and curvature, so a draw that moves at a constant rate along the path looks uneven on screen. Uneven point spacing also makes kinks visible as the stroke passes through them. On the web, every point adds bytes and rendering work.

A related cause is stacked or duplicated paths: the same line drawn twice on top of itself, or a stroke that doubles back along its own route. When trimmed, these draw twice or in an unexpected order.

The fix

Simplify before you animate. In Illustrator, the Simplify command reduces anchor points while holding the shape, and for important lines redrawing by hand with the Pen tool gives the cleanest result: points only at the ends of curves and at genuine changes of direction, with handles roughly in line with the flow of the curve. Delete stray points, join paths that should be continuous, and remove duplicates. For handwriting and signatures, don't try to trim the filled outline of the letters. Draw a single centerline stroke that follows the pen's path and use it as a matte to reveal the filled lettering, or animate it as the visible stroke itself.

For web delivery, run the SVG through an optimizer such as SVGO, but check what it did. Optimization can merge separate paths into one, which breaks per-path staggering, and it can round coordinates enough to shift a start point. Configure it to keep the paths and IDs you animate, and measure path lengths after optimization, not before.

Quick fix: Turn on anchor point display in Illustrator or After Effects and look at the path. If you can't count the points at a glance, there are too many. A clean icon stroke usually needs only a handful of points per curve.

Preventing it

Treat line art as animation-ready only when it has been checked for point count, duplicates and direction. Hand-built vector work takes longer at the design stage and saves time at every stage after it. This is equally true in whiteboard-style work, where the drawn line carries the whole piece. Our guide to whiteboard-style animation done properly goes further into drawing reveals.

The Web Version Doesn't Match the Video Version

How to recognize it

A line animation approved as a video is rebuilt for a landing page or an app, and it doesn't look the same. Lines draw in a different direction, the timing feels different, some lines draw fully while others stop short or overshoot, or the effect works in one browser and not another.

Likely causes

The two builds rest on different mechanisms. Trim Paths works in percentages of path length and handles sequencing, offsets and both ends at once. SVG dashing needs an accurate length per path, so if the length is measured on the unoptimized file and the paths change afterward, lines will stop short or show a gap. Path direction can also change between the After Effects composition and the exported SVG, especially when artwork has been through several tools. Easing curves from the After Effects Graph Editor don't translate automatically to CSS timing functions, so the web draw often loses the shaped acceleration the video had.

If you export through Lottie from After Effects, most trim path setups carry across, but not every After Effects feature is supported by every Lottie player, and expression-driven timing may not survive. Check the player's supported feature list against your composition before committing to that route.

The fix

Decide the target formats at the start and build the source artwork for the stricter one. For shared work, that usually means one clean SVG per line set, with direction, start points and stacking order checked, used as the source for both the After Effects composition and the web build. Re-measure lengths with getTotalLength() in the final file, or use pathLength so the exact number stops mattering. Translate easing deliberately: read the influence and speed values from the After Effects keyframes and approximate them with a cubic-bezier, then compare the two side by side at the same frame rate.

Handle accessibility on the web. Respect the prefers-reduced-motion media query, and for users who ask for reduced motion, show the lines already drawn rather than removing them, because the lines usually carry meaning. Keep the number of simultaneously animating strokes modest on mobile, since animating dash offsets causes repainting on every frame.

Preventing it

Export SVG animations with clean paths, and treat the SVG as a deliverable in its own right, with a spec: viewBox, stroke widths, caps, path IDs, direction and draw order. Our practical guide to delivering animation source files covers what a complete handoff package should contain. Product teams building draw-on effects into software can find more on this in our guide to product UI demo animation.

Worked Example: Fixing a Route Line Built for Video and Web

The following project is illustrative. It is a composite of the kind of job studios see regularly, not a specific client, and the numbers are realistic working values rather than benchmarks.

A logistics company wants a route line to draw across a stylized map in a 30-second explainer video at 1920 by 1080 and 30 frames per second, and the same route to draw on the homepage as an SVG. The designer supplies an Illustrator file with the route, four stop markers drawn as circles, and four short connector lines to labels.

What the first pass looked like

The animator imports the artwork, adds one Trim Paths to the group, keyframes End from 0% to 100% over 150 frames (five seconds), and leaves Trim Multiple Shapes on Simultaneously. On review, the route draws from destination to origin, the four circles start at three o'clock and draw along with the route, the connectors appear during the route draw rather than as each stop is reached, and the route slows noticeably through the city section. The route was auto-traced from a map and has around 340 anchor points. The circles look heavier than the route because the imported group was scaled to 80% and the circles were then scaled back up in their own group.

The diagnosis and fixes

ProblemCause foundFix appliedEffect on timing
Route draws backwardPath direction runs destination to originPath direction reversed at the sourceNone
Route stutters in the cityAbout 340 points from auto-traceRedrawn by hand with about 30 pointsPerceived speed evens out
Circles heavier than routeNested group scales of 80% and 125%Scales reset to 100%, geometry resized; all strokes 6 pxNone
Everything draws at onceOne trim set to SimultaneouslySeparate trims per element, staggered to the routeSequence now reads in story order
Draw feels slow150 frames, linear keyframesRoute cut to 75 frames with eased keyframesSaves 75 frames (2.5 seconds)
Circles start at three o'clockDefault first vertexOffset of -90 degrees so each starts at twelveNone

The rebuilt timing

The route now draws over 75 frames with an ease-out-weighted curve. The four stops sit at roughly 20%, 45%, 70% and 100% of the route's length. Each stop circle starts drawing when the route's leading edge reaches it and takes 12 frames. Each connector line starts 6 frames after its circle begins and takes 9 frames. The final stop's circle starts at frame 75 and its connector finishes at frame 90, exactly three seconds in, against five seconds for the route alone in the first pass, and the viewer now sees each stop as it is reached rather than a tangle of simultaneous lines.

Because the stops are placed by percentage along the route, not by frame number, an expression on each circle's start time reads the route's End value and triggers when it passes the stop's percentage. If the director later asks for a 90-frame route, only the route's keyframes change and everything else follows.

The web build

For the homepage, the corrected Illustrator file is exported as SVG with one path per element and IDs matching the After Effects layer names. Each path gets pathLength="1", so the dash values are 1 regardless of the route's true length. The route's 75 frames become a 2.5-second CSS animation, and the stop delays convert directly from frames to seconds at 30 frames per second. The After Effects ease curve is approximated with a cubic-bezier and compared to the video side by side. Under prefers-reduced-motion, the route and markers appear fully drawn. The optimizer is configured not to merge paths, and the file drops to a fraction of the auto-traced size because most of the weight was in the original anchor points.

The fixes took longer to diagnose than to apply, and nearly all of them came from source artwork that was never checked for direction, scale or point count. Checking at handoff would have avoided every one of them.

Prevention Checklist for Trim Paths and Line Animation

Run this before animating any line set, and again before exporting for the web. Each item maps to one of the symptoms above.

  • Target formats agreed: video only, web only, or both, with frame rate, resolution and browser support written down.
  • Path direction checked on every path with a temporary trim, and matching the agreed convention.
  • First vertex of every closed shape placed where the draw should begin.
  • All layer and group scales at 100%, with artwork sized by geometry.
  • Stroke widths drawn from the approved set, and no stroke thinner than the delivery size can hold.
  • Caps and joins specified and consistent across the piece.
  • Anchor points reduced to the minimum that holds the shape, with duplicates removed.
  • Paths named and stacked in draw order.
  • Draw durations and easing curves taken from the project's timing scale.
  • First and last frames of every draw checked at full resolution for dots, gaps and notches.
  • For web: path IDs kept through optimization, lengths measured after optimization or pathLength set, and a reduced-motion state defined.
  • Timing reviewed in the finished sequence, with audio, not in isolation.

The checklist looks long, but on clean artwork most items take seconds. On problem artwork, it finds the fault before a client does.

Choosing the Right Line Technique, and When to Get Help

Matching the technique to the line

Not every drawn line needs Trim Paths, and some problems are best solved by picking a different technique rather than fixing the one you started with.

Trim Paths is the right default for vector strokes in After Effects: icons, diagrams, route lines, underlines and outlines. With Stroke Taper and Wave, available on shape-layer strokes in recent versions, it can also do tapered brush-like lines without switching tools. For revealing filled artwork such as lettering or a logo mark, use a trimmed stroke as a track matte over the fill rather than trimming the fill's outline, which draws both sides of each letter at once. For genuinely hand-drawn lines with variable pressure and texture, frame-by-frame drawing or a tool built for it often looks more natural than any stroke operator. Our article on frame-by-frame animation covers that option, and Blender's Grease Pencil is another route worth considering.

On the web, dash-offset drawing is right for a handful of paths on a page. For many paths, complex sequencing or animations that must exactly match a video, a Lottie export or a JavaScript animation library gives more control, at the cost of a runtime dependency. For a simple icon draw-on inside a product, plain CSS is usually enough and is the lightest option.

Line animation also sits inside larger formats. Explainer and training content leans on it heavily, and our guides to animation for e-learning and employee onboarding animation show where drawn lines help comprehension and where they just add motion for its own sake.

When to bring in specialist help

Most of the fixes in this manual are within reach of a competent in-house designer with After Effects and a developer comfortable with SVG. The point to bring in help is when line animations must work in both video and web contexts and look the same in each. At that point you are no longer making one animation. You are building a small system: shared source artwork, a stroke and timing specification, an After Effects build, a web build and a way to keep them in sync when changes come in.

Other signs it is time to get help: a large icon or diagram set that must animate consistently across a product and its marketing, source artwork arriving from several designers with no shared conventions, a brand mark or signature that has to draw perfectly because it will be seen thousands of times, or a deadline that leaves no room for the diagnosis loop in the worked example.

When you brief a studio, send the source artwork, the target formats and sizes, any timing or voiceover constraints, and examples of line animation you like. Ask how they will handle direction, stroke consistency and the web handoff. The answers will tell you quickly whether they have built dual-format line work before. Our guide to choosing an animation studio covers the wider selection process, and our animation and motion graphics services include line animation built for both video and web delivery.

Verdict Nearly every line animation fault traces back to the path, not the animation: its direction, its scale, its point count or its start vertex. Fix and standardize the source artwork first, set a stroke and timing system, then animate. Done in that order, trim paths and line animation become one of the fastest, lightest and clearest tools in motion design.

Where this comes from

The figures and practices above come from the sources listed.

Working on something like this?

We take on Motion Graphics & Animation work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.

Where to go next

Spotted something wrong? Report an error on this page. We correct on the page and say what changed.

Frequently asked questions

Trim Paths follows the order in which the path's points were created, which you can't see in a still frame. Either animate the Start property instead of End, reverse the path direction, or use Set First Vertex for closed shapes. Checking direction with a temporary trim before animating avoids the problem.
Set stroke-dasharray to the path's length, set stroke-dashoffset to the same value so the line is hidden, then animate the offset to zero. You can measure the length with getTotalLength() or set pathLength to 1 so the values are always 1. The line draws from the path's first point.
Stroke width scales with the layer and group transforms above it. Keep scale at 100% and resize the path geometry, or use an expression that divides the stroke width by the scale factor. In SVG, non-scaling-stroke or consistent viewBox sizes solve the same problem.
There is no fixed rule, but short icon strokes usually feel right well under a second and longer diagram or route lines in the one to three second range. The test is whether the viewer ever waits for the line to finish. Review timing in the finished sequence, not in isolation.
Round and square caps extend past the end of the path, so a zero-length segment can still render as a small dot. Hide the stroke until the draw begins, or make the dash gap slightly longer than the path plus the cap. Check the first frame at full resolution to confirm it is gone.
Yes, either by rebuilding them as SVG dash-offset animations or by exporting through Lottie. Check that your Lottie player supports the features you used, and re-measure path lengths after any SVG optimization. Starting from one clean source file keeps the two versions consistent.
All services

The work behind this article, and what it costs.

See it in practice

All the work
Before: Stabilization: Shaky Night-Market Walk to a Smooth Glide
After: Stabilization: Shaky Night-Market Walk to a Smooth Glide
Original handheld Stabilized

Stabilization: Shaky Night-Market Walk to a Smooth Glide

Two-pass motion analysis (block phase correlation, robust similarity fit), Gaussian path smoothing, per-frame rotate and crop, light temporal denoise

Studio demo on a public-domain photo, not a client job

Watch the video

Video Stabilization Travel & Lifestyle 24-48 hours

Before: Green Screen: Rotating Food Product Keyed into a Café Scene
After: Green Screen: Rotating Food Product Keyed into a Café Scene
Green-screen source Keyed + composited

Green Screen: Rotating Food Product Keyed into a Café Scene

Chroma key, despill, color matching, background defocus and vignette, compositing (ffmpeg)

Studio demo on a public-domain photo, not a client job

Watch the video

Green Screen Compositing Food & Restaurant 24-48 hours

Before: Cinematic Grade: Flat Drone Footage to a Moody Film Look
After: Cinematic Grade: Flat Drone Footage to a Moody Film Look
Original flat footage Cinematic grade

Cinematic Grade: Flat Drone Footage to a Moody Film Look

Filmic tone curve, split toning, graduated sky filter, vibrance, vignette and sharpening, with a wipe compare video

Studio demo on a public-domain photo, not a client job

Watch the video

Cinematic Color Grading Travel & Tourism 24-48 hours

MediaScaleUp Editorial Team

Articles here are researched, written and checked by the MediaScaleUp studio team before they are published, and dated when they are reviewed.

Keep reading

More in Motion Graphics & Animation