🔨 All in one Utilities

Interactive SVG Animation Builder

Great utilities that help you design, program and maintain your website

utilities for you to make a website
Home » Utilities » Interactive SVG Animation Builder

Interactive SVG Animation Builder

Script elements and event attributes are stripped before the preview renders.

Note: None of this runs if the SVG is used as an img source or a CSS background — those render in a restricted mode with external CSS and scripting disabled. Inline the SVG into your HTML for the animation to apply.

SVG animates two ways and they behave nothing alike. CSS keyframes treat the SVG's elements as ordinary boxes you can transform, fade and recolour, which is fast, hardware-accelerated and debuggable in devtools. SMIL — the animate elements written inside the SVG file itself — can do things CSS cannot, notably animating path geometry, but it does not run when the SVG is used as an img src or a CSS background, which is where most icons end up.

The draw-on effect is the one people come here for. It works by turning the outline into a dashed stroke whose single dash is exactly as long as the path, then animating the dash offset from that length down to zero, so the line appears to be drawn. The critical number is the path length, and getting it wrong is why the effect so often starts with a visible chunk already drawn or finishes early. This builder measures each path with getTotalLength and writes the real figure into the keyframes rather than the usual guessed round number.

Paste your own SVG or start from one of the samples. The preview runs the animation live, so timing, easing and stagger can be judged rather than calculated — a stroke draw that reads well at 1.2 seconds looks broken at 400 milliseconds no matter what the numbers say.

The output includes a prefers-reduced-motion block. Looping animation is a genuine accessibility problem for people with vestibular disorders, and an icon that draws itself once on load is fine while the same icon looping forever is not.

Frequently Asked Questions

Why does my animation not run when I use the SVG in an img tag?

An SVG loaded through img, or as a CSS background, is rendered in a restricted mode where external CSS does not apply and scripts do not run. Only styles written inside the SVG file itself take effect, and SMIL animation is disabled entirely. Inline the SVG into your HTML if it needs to animate.

How is the path length calculated?

With getTotalLength on each path element, measured in the browser after the SVG is parsed. That is the accurate figure. Hardcoding a large round number like 1000 works only by accident: it makes the dash longer than the path, so the animation appears to start partway through.

Should I use CSS or SMIL?

CSS for almost everything — transforms, opacity, colours, stroke offsets — because it composites on the GPU, respects reduced-motion queries and can be inspected in devtools. SMIL only when you need to animate the path data itself, which CSS still cannot do without a library.

Why does my transform animate from the wrong point?

Because in SVG, transform-origin defaults to the origin of the SVG coordinate system, not the centre of the element as it does in HTML. A spin therefore orbits the top-left corner. Setting transform-box: fill-box along with transform-origin: center fixes it, and the generated CSS includes both.

Related Utilities