Paste SVG code from Figma or Illustrator, or click to draw a path, then adjust the timing in the live preview. Copy the CSS and HTML, or download one SVG file with the animation built in.
This tool runs entirely in your browser. What you enter is never sent anywhere.Your input is never sent anywhere.
DetailsUse original colors keeps the stroke and fill colors written in your pasted SVG. A shape with only a fill gets an outline in its fill color. It is not available for path data alone, which has no color information. Fade out outline removes the outline after the fill appears. With Use original colors on, it affects only shapes that have a fill and no stroke in your SVG.
Plays when the page loads.
Use this with the SVG in the HTML tab.
.svg-draw {
fill: none;
stroke: #6366f1;
stroke-width: 4;
stroke-linecap: round;
stroke-linejoin: round;
}
.svg-draw-1 {
stroke-dasharray: 1;
stroke-dashoffset: 1;
animation: svg-draw 1.5s ease-in-out 0s infinite;
}
@keyframes svg-draw {
to {
stroke-dashoffset: 0;
}
}
/* Show the finished drawing to people who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
.svg-draw {
animation: none !important;
transition: none !important;
stroke-dashoffset: 0 !important;
}
}How stroke-dashoffset makes an SVG path draw itself
This generator writes the CSS that makes SVG paths draw themselves. It sets stroke-dasharray to the measured length of each path, then animates stroke-dashoffset from that length down to 0, so the line appears as if a pen were drawing it. Paste SVG code or load an .svg file, and the tool finds the shapes, measures each one with getTotalLength() in your browser, and writes the numbers into the CSS. If you do not have an SVG, click on the canvas to place points and it builds the path for you. The output covers staggered delays for multiple paths, reverse playback, a fill that appears after the stroke, hover and scroll triggers, and a prefers-reduced-motion rule.
Uses for line-drawing SVG: logos, checkmarks, and underlines
Animated logo outline
Paste the logo SVG, turn on Use original colors and Fill after stroke, and the outline draws first, then the original colors fade in. Add Fade out outline if you want the outline gone once the fill is in.
Checkmark and arrow hover effects
Set the trigger to On hover. The line draws when the pointer enters the SVG and erases when it leaves, using CSS transitions only.
Hand-drawn underline on a landing page
Use Click to draw to place a few points, leave Smooth curve on, and choose On scroll. The line draws once when 10% of the SVG is on screen.
Animated SVG for a CMS or an img tag
Download animated SVG gives you one file with the CSS inside. Upload it to a platform that accepts SVG images and keeps the embedded CSS, and it plays without extra HTML or CSS.
Animate a Figma or Illustrator SVG in 5 steps
- Choose Paste SVG, then paste the SVG code from Figma or Illustrator, or only the d attribute of a path. You can also click Choose file or drop an .svg file onto the box. With no SVG on hand, switch to Click to draw and place points on the canvas.
- Set Duration, Delay between paths, Start delay, and Easing, then pick the Stroke width and Stroke color.
- To reveal a fill, turn on Fill after stroke and set the Fill color and Fill duration. To keep the colors from your SVG, turn on Use original colors.
- Under Trigger, pick On load, On hover, or On scroll. Press Replay to watch the animation again.
- Copy the CSS and HTML tabs (plus the JS tab for On scroll) into your page, or click Download animated SVG for a single file with the CSS embedded.
Note: Auto-fit view box is on by default. It measures the drawn shapes and sets a view box with padding, so SVGs exported with large artboard coordinates still fit in the preview. The HTML tab uses the same view box.
SVG import limits: supported shapes, colors, and text
- Path length: the tool calls getTotalLength() on each path in your browser. Lengths are in SVG user units, and the badge in the preview shows the number of shapes and the total length.
- Supported shapes: path, line, polyline, polygon, rect, circle, and ellipse, up to 24 shapes. Each is converted to a path. Shapes with percentage values or zero size are skipped, and shapes inside defs, clipPath, mask, symbol, pattern, marker, gradient, and filter elements are ignored.
- Text and use: text elements are not supported, so convert text to outlines before exporting. Shapes referenced through use elements are not supported either.
- Colors: stroke and fill are read from attributes, style attributes, and single-class rules such as .cls-1 in a style element. Gradients and other url() references are ignored, so those shapes count as having no color. A fill that is not set is treated as black, as in SVG.
- Transforms: transform attributes on shapes and parent groups are carried over to the output paths.
- Delays: with Loop on, Start delay and Delay between paths apply to the first run only. Start delay is ignored for On hover.
- Limits: .svg files up to 2 MB, and up to 60 points in Click to draw.
- Use the CSS and HTML together. The HTML contains the classes the CSS targets: svg-draw-root, svg-draw, and svg-draw-1, svg-draw-2, and so on.
- Downloaded SVG file: playback is set to On load, whatever trigger is selected.
CSS properties behind SVG stroke-dasharray animation
The properties used for line drawing, and what this generator writes for each one.
| Property | What it does | What the generator writes |
|---|---|---|
| stroke-dasharray | Sets the dash length and the gap length | The measured path length for each shape, rounded to a whole number (minimum 1), so one dash covers the whole path. |
| stroke-dashoffset | Shifts where the dash pattern starts | Starts at the path length and animates to 0, which reveals the line. The keyframes are generated too. |
| fill-opacity | Sets how transparent the fill is | With Fill after stroke on, it goes from 0 to 1 after the stroke finishes. |
| stroke-opacity | Sets how transparent the outline is | With Fade out outline on, it goes from 1 to 0 while the fill appears. With Use original colors on, only shapes that have a fill and no stroke of their own are faded. |
| animation-delay | Delays the start of the animation | Start delay + Delay between paths × (shape number − 1), so the first shape starts after the Start delay alone. |
| animation-direction | Sets the playback direction | Reverse (erase) adds reverse, so the line erases instead of drawing. |
| animation-fill-mode | Keeps the first or last frame outside the run | Loop off adds forwards so the last frame stays. Reverse (erase) adds backwards so the drawn line shows during the delay. |
| transition | Smooths a change between two states | With On hover, drawing and erasing use transitions instead of keyframes. |
| prefers-reduced-motion | Media query for reduced-motion settings | Turns off the animation and transition and shows the finished drawing. |
| viewBox | Sets the visible area of the SVG | Read from your SVG, or built from width and height if it is missing. Auto-fit view box calculates it from the bounding box of the shapes. |
CSS only on load and hover
The On load and On hover outputs need no JavaScript. Inline SVG also adds no extra image request. The On scroll output adds a short script that only adds a class when the SVG comes into view.
Browser support
The CSS uses standard animations and transitions, with no libraries. The scroll trigger uses IntersectionObserver, which current Chrome, Safari, Firefox, and Edge support.
Scroll triggers, staggered paths, hover, and filled logos
What to set when a single draw-on-load line is not enough for the page you are building.
Play the drawing when it scrolls into view
An animation that plays on page load can finish before anyone scrolls to it.
Choose On scroll and the tool outputs CSS that runs only when the SVG has an is-visible class, plus a short IntersectionObserver script in the JS tab. The script adds the class once 10% of the SVG is on screen, then stops watching it, so the drawing plays once.
Load the script after the SVG, for example just before the closing body tag.
Draw several paths one after another
Paths are drawn in the order they appear in the SVG code.
The Delay between paths slider (0 to 1 second) sets how long after the previous path each path starts. With a 1.5-second Duration and a 0.2-second delay, path 2 starts at 0.2 s and path 3 at 0.4 s, so the strokes overlap.
For a strict sequence, set the delay at least as long as the Duration, for example 0.5 s for both. Set the delay to 0 to draw every path at once.
Draw on hover, erase on leave
For icons in buttons and navigation, the motion on leave matters as much as the motion on enter.
With On hover, the tool uses a transition on stroke-dashoffset: the line draws while you hover the SVG and erases when the pointer leaves.
With Fill after stroke on, entering draws the stroke and then fades the fill in, and leaving fades the fill out and then erases the stroke.
Filled logos: outline first, fill second
A shape that has only a fill shows nothing when you animate stroke-dashoffset, because there is no stroke to reveal.
Turn on Use original colors to give it an outline in its fill color, and Fill after stroke to fade the fill in after the outline is drawn. The outline stays on top of the fill, which makes the shape look slightly bolder than the original.
Turn on Fade out outline to remove the outline once the fill is in. With Use original colors on, it affects only shapes that have a fill and no stroke of their own.
Simplify paths and outline text before export
A path with too many anchor points makes a long d attribute and a larger HTML file. Simplify the path in Figma or Illustrator before exporting, as far as the shape still looks right.
Text is not drawn, because a text element has no path. Convert text to outlines first, then export the SVG.
SVG draw animation not working? Causes and fixes
The line stops short or starts late because stroke-dasharray was guessed
Typing a stroke-dasharray value without measuring the path gives the wrong length. Too short, and the line stops partway or shows as dashes. Too long, and there is a blank pause before the line appears. Every edit to the shape changes the length, so the number has to be redone each time.
💡 See the solution▼
Only part of the logo animates
Logos exported from Figma or Illustrator often mix path, rect, circle, and ellipse elements. Copying a single d attribute, or using a method that handles only path elements, animates only part of the logo.
💡 See the solution▼
A filled logo draws nothing, or its color changes
Most logos and icons are built from fills, not strokes. A line-drawing animation on a fill-only shape draws nothing when there is no stroke, or draws an outline in a color you did not choose.
💡 See the solution▼
The drawing is tiny, off-center, or clipped
Design tools can export coordinates in the hundreds or thousands. If the viewBox is still 0 0 100 100, shapes fall outside it. If a small shape sits in a large viewBox, it shows as a dot and the motion is hard to see.
💡 See the solution▼
The line disappears as soon as the animation ends
Without animation-fill-mode: forwards, an element returns to its starting state after the last frame, and the starting state here is the hidden line.
💡 See the solution▼
Text in the SVG does not draw
A text element has no path, so there is nothing to measure or animate with stroke-dashoffset. The tool skips text elements and shows a notice.
💡 See the solution▼
SVG line animation: frequently asked questions
Q.How do I make an SVG path draw itself with CSS?
A. Set stroke-dasharray to the path length, set stroke-dashoffset to the same value, then animate stroke-dashoffset to 0. This tool writes that CSS for you: paste your SVG, check the preview, and copy the CSS and HTML tabs. The On hover trigger outputs CSS with transitions, and On scroll adds a short script that toggles a class.
Q.How do I find the length of an SVG path for stroke-dasharray?
A. Paste the SVG and the tool measures it for you. It runs getTotalLength() on each path in your browser, rounds the result to a whole number, and writes it into stroke-dasharray and stroke-dashoffset. The preview badge shows the number of shapes and the total length. The finished CSS has the numbers built in, so On load and On hover need no JavaScript on your page.
Q.Which part of a Figma or Illustrator export should I paste?
A. Paste everything from the opening svg tag to the closing tag, or use Choose file or drop an .svg file (up to 2 MB). The tool detects path, line, polyline, polygon, rect, circle, and ellipse elements and converts each one to a path. Transforms on shapes and parent groups are kept. You can also paste only the d attribute of a single path.
Q.How do I draw several paths one after another?
A. Raise Delay between paths. Each path starts that many seconds after the previous one, in the order the shapes appear in the SVG code. For a strict sequence, set the delay at least as long as Duration. Set it to 0 to draw every path at once. Up to 24 shapes are detected.
Q.Why does my filled SVG logo show nothing when I animate the stroke?
A. A shape that has only a fill has no stroke to draw. Turn on Use original colors so the shape gets an outline in its fill color, then turn on Fill after stroke to bring the fill in once the outline is drawn. Fade out outline removes the outline at the end, so the finished logo is not thickened by it.
Q.Can the line draw on hover or when the SVG scrolls into view?
A. Yes. Under Trigger, choose On hover or On scroll. On hover outputs CSS only: the line draws when you hover the SVG and reverses when the pointer leaves. On scroll outputs CSS plus a short IntersectionObserver script (JS tab) that adds an is-visible class when 10% of the SVG is on screen, so it plays once.
Q.Can I use the animated SVG in an img tag or upload it to a CMS?
A. Yes, if the platform accepts SVG uploads and keeps the CSS inside the file. Click Download animated SVG to get one file with the CSS embedded. It plays in an img tag. Playback is fixed to On load, so the On hover and On scroll settings do not apply. The SVG tab shows the same code if you prefer to copy it.
Q.What can I do if I do not have an SVG path?
A. Switch to Click to draw and click the canvas to place points. They connect in click order and the d attribute is created for you. Smooth curve rounds the segments, Close path joins the last point to the first, and Undo last point removes the latest point. You can place up to 60 points. The drawing plays in the preview right away and exports as CSS and HTML.
Q.Does the generated CSS respect prefers-reduced-motion?
A. Yes. The CSS ends with a prefers-reduced-motion: reduce rule that turns off the animation and transition and shows the finished drawing. It is included in the On load, On hover, and On scroll outputs.
Q.Why is my SVG too small or cut off in the preview?
A. Design tools can export coordinates in the hundreds or thousands, which do not match a small viewBox. Auto-fit view box measures the drawn shapes and sets a view box with padding based on the shape size and stroke width. Turn it off to keep the view box from your SVG.
Q.Do these animations work in Chrome, Safari, and Firefox?
A. Yes. The output uses standard CSS animations and transitions with no libraries, and these run in current versions of Chrome, Safari, Firefox, and Edge, including mobile browsers. The scroll trigger also relies on IntersectionObserver, which those browsers support.
Q.Is my SVG uploaded to a server?
A. No. Pasted code, loaded files, and settings are processed in your browser only. Nothing is sent or stored, and the data is gone when you close the page.
Your feedback
makes this tool better.
Tell us which features you'd like, what should be fixed, or which new tool you'd like to see. An engineer reads every submission and uses it to guide development.