CSS Free, no sign-up

SVG animation generator

Choose a shape, colors and an effect — the animated SVG plays in the preview, and below you get the inline SVG markup together with the CSS @keyframes, ready to paste into your page.

Result
Ready-made CSS
<svg viewBox="0 0 100 100" width="160" height="160" aria-hidden="true">
  <polygon
    class="shape"
    points="50,20.2 58.5,41.4 81.4,43 63.8,57.6 69.4,79.8 50,67.7 30.6,79.8 36.2,57.6 18.6,43 41.5,41.4"
    fill="#fbbf24"
    stroke="#b45309"
    stroke-width="4"
    stroke-linejoin="round"
    stroke-linecap="round"
  />
</svg>

.shape {
  transform-box: fill-box;
  transform-origin: 50% 55%;
  animation: spin 2s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .shape {
    animation: none;
  }
}

How to use it

  1. Pick a shape — circle, square, star, heart or check mark — and set the fill color, the stroke color and the stroke width.
  2. Choose an effect: rotate (rotate), pulse (scale), bounce, fade, draw the outline with stroke-dasharray, or color shift (fill and stroke swap places).
  3. Tune the duration, delay, number of repeats, timing function and direction. The “Pause” and “Restart” buttons in the preview help you inspect the animation.
  4. Click “Copy” and paste the SVG into your HTML and the CSS into your stylesheet. The prefers-reduced-motion block is already included.

How it works

Why animate SVG with CSS

Inline SVG elements are part of the DOM, so you can style and animate them with ordinary animation and @keyframes — no JavaScript or library needed. This works for <circle>, <rect>, <path> and other shapes, but not for SVG loaded through <img> or background-image: the page CSS cannot reach into such a file, so the animation has to be written inside the SVG itself.

transform-box and transform-origin

In SVG the default transform origin is the top-left corner of the whole drawing (0 0), so a rotation swings the shape around the wrong point. transform-box: fill-box ties the origin to the shape's own bounding box, and transform-origin: center puts it in the middle. A five-point star is bottom-heavy: its visual center sits at about 55% of the box height, so the generator uses 50% 55% for it.

.shape {
  transform-box: fill-box;
  transform-origin: center;
}

Drawing a stroke: dasharray and dashoffset

stroke-dasharray sets the length of dashes and gaps, stroke-dashoffset shifts that pattern. If the dash is as long as the whole outline and the offset equals that length, the line is invisible; animating the offset to 0 “draws” it. The length is measured in user units: the generator uses a value slightly above the outline length so no dot is left at the end. For your own shape you can get the length with getTotalLength(). On filled shapes the generator also fades the fill in with fill-opacity.

@keyframes draw {
  from { stroke-dashoffset: 177; }
  to { stroke-dashoffset: 0; }
}

Respect prefers-reduced-motion

Constant movement can cause discomfort for people with vestibular disorders, which is why operating systems have a “reduce motion” setting. The generator adds a @media (prefers-reduced-motion: reduce) block that turns the animation off; the base styles stay fully visible, so nothing disappears. Decorative SVG should also get aria-hidden="true".

@media (prefers-reduced-motion: reduce) {
  .shape { animation: none; }
}

FAQ

Can I animate an SVG used in an img tag?

Not with your page's CSS: page styles do not reach inside an <img>. Put a <style> with @keyframes into the SVG file itself, or inline the SVG into your HTML.

Why does my SVG rotate around the wrong point?

Because the default transform origin is the top-left corner of the drawing. Add transform-box: fill-box and transform-origin: center.

CSS animation or SMIL (the animate element)?

CSS is easier to combine with the rest of your styles and responds to media queries, including prefers-reduced-motion. SMIL lives inside the SVG and also works in all modern browsers, but is used less often.

Is SVG animation heavy for the browser?

Animating transform and opacity is cheap. Animating the d attribute, filters or hundreds of elements at once costs more — test on low-end phones.

This topic in the HTML & CSS course

More CSS tools

CSS gradient generator Linear, radial and conic gradients: pick colors, angle and stops, then copy the code. Flexbox generator and playground Try flex properties on a container and its items: direction, alignment, gaps and ready-made CSS. CSS Grid generator Set columns and rows, gaps and alignment, then copy the ready-made grid code. CSS box-shadow generator Pick offset, blur, color and layers for a shadow, then copy the ready-made box-shadow code. Cubic-bezier generator Drag the control points of an easing curve and copy the ready-made CSS transition. CSS specificity calculator Type selectors to see their (a,b,c) weight, a color-coded breakdown and which rule wins. CSS box model visualizer See content, padding, border and margin as a DevTools-style diagram and copy the CSS. CSS transform generator Move, rotate, scale and skew an element, see its original position and copy the code. CSS clamp() calculator Enter min and max font size and viewport width — get a ready clamp() for fluid typography. Color contrast checker (WCAG) Check text and background contrast against WCAG AA and AAA, and fix a failing pair of colors. CSS clip-path generator Polygons, bevels, arrows and circles: drag control points on the live canvas and copy ready-made CSS. CSS glassmorphism generator Frosted glass effect: backdrop-filter blur, saturation, border highlight and clean CSS. CSS border-radius (Blob) generator Organic shapes and 8-value border-radius: tune horizontal and vertical corner radii. CSS Stacking Context & z-index Visualizer Why z-index: 9999 fails! Explore CSS Stacking Contexts in interactive 3D exploded layers with transform, opacity and isolation triggers. CSS aspect-ratio & object-fit Generator Eliminate squished images & CLS layout jumps: live aspect-ratio proportions and interactive object-position focal point. CSS Filters Studio & Generator Photo effects without design tools: blur, contrast, hue-rotate, sepia, and trending Instagram-style presets. OKLCH Color Picker & Palette Generator Perceptually uniform brightness & vibrant Display P3 colors: OKLCH picker, design system scales, and fallbacks. CSS Scroll-driven Animations Generator Scroll-linked animations without JavaScript: animation-timeline scroll() & view(), reading progress bar & reveal on scroll. CSS Container Queries (@container) Generator Beyond viewport media queries: components adapt directly to their parent container width. Live resizer & @container rules.
WhatsApp