SVG `stroke-dasharray` Animation Calculator
Calculate dash values, generate path-drawing animations, and preview SVG stroke effects locally.
Calculator
Preview
Results
Metrics
Introduction
SVG stroke animations are commonly created using stroke-dasharray and
stroke-dashoffset. To draw a path, the dash length usually needs to match
the total path length.
This calculator measures the path and generates the required CSS values locally.
How it works
The tool extracts the path data, measures the path length where possible, and generates CSS for either a one-time draw animation or an infinite dash movement effect.
- Path length is measured with SVG path APIs.
- Manual length override is supported.
- Preview uses the Web Animations API where available.
- Reduced-motion fallbacks are optional but recommended.
How to use
- Paste SVG path data or full SVG markup.
- Select draw or dash mode.
- Set duration and dash values.
- Calculate and preview.
- Copy the CSS and SVG snippets.
Practical example
For a path length of 240, a draw animation typically uses:
stroke-dasharray: 240;
stroke-dashoffset: 240;
Then animate stroke-dashoffset to zero.
Use cases
- Animated icons.
- Onboarding illustrations.
- Diagram drawing effects.
- Loading indicators.
- Decorative line reveals.
Best practices
- Keep animations short and purposeful.
- Provide reduced-motion fallbacks.
- Avoid infinite motion for large decorative areas.
- Test on low-powered devices.
- Use easing to make draws feel natural.
Common mistakes
- Using an incorrect path length.
- Animating stroke width instead of dash offset.
- Using very long durations for long paths.
- Forgetting reduced-motion users.
- Overusing infinite dash movement.
Limitations
- Path length measurement may fail for invalid path data.
- Preview depends on browser animation support.
- Very complex paths may be expensive to animate.
- Rounding may slightly affect very long paths.
Browser compatibility
SVG stroke animation works in current versions of major browsers. The Web Animations API is used for preview where available.
FAQ
Is my SVG uploaded?
No. Path data is processed locally in your browser.
Why does draw animation need path length?
The dash length must cover the full path length so the path can start fully hidden and reveal smoothly.
Can I use this for icons?
Yes. It works well for stroke-based icons, illustrations, and decorative line effects.
Should I include reduced motion support?
Yes. Users who prefer reduced motion may experience discomfort from animated strokes.