SVG Path Length Calculator

Calculate path length for stroke animations

Path Length Calculator

Total Path Length
units
Rounded
CSS for Line Draw Animation
/* Enter a path to generate CSS */

How to Use Path Length for Animations

The stroke-dasharray and stroke-dashoffset CSS properties let you create line drawing animations. By setting both to the total path length, then animating stroke-dashoffset to 0, you create the illusion of the path being drawn.

Step-by-Step

  1. Get your SVG path's d attribute
  2. Paste it above to calculate the total length
  3. Copy the generated CSS
  4. Apply the CSS class to your path element

JavaScript Alternative

var path = document.querySelector('path');
var length = path.getTotalLength();

path.style.strokeDasharray = length;
path.style.strokeDashoffset = length;

// Trigger animation
path.style.transition = 'stroke-dashoffset 2s ease-in-out';
path.style.strokeDashoffset = '0';

SVG Path Commands Reference

Command Name Parameters
MMove tox y
LLine tox y
HHorizontal linex
VVertical liney
CCubic Bézierx1 y1 x2 y2 x y
SSmooth cubicx2 y2 x y
QQuadratic Bézierx1 y1 x y
TSmooth quadraticx y
AArcrx ry angle large-arc sweep x y
ZClose path(none)

Lowercase commands use relative coordinates. Uppercase commands use absolute coordinates.

FAQ

Why do I need the path length?

For stroke animations, you need to know the exact length to set stroke-dasharray and stroke-dashoffset correctly. If these values don't match the actual path length, the animation won't look right.

What units is the length in?

The length is in SVG user units, which correspond to the coordinate system defined by your viewBox. If your viewBox is "0 0 100 100", a path from (0,0) to (100,0) would have a length of 100 units.

Can I animate multiple paths?

Yes! Calculate the length for each path separately and apply individual animations. Use animation-delay to sequence them.

Privacy & Limitations

  • All calculations run entirely in your browser -- nothing is sent to any server.
  • Results are computed locally and should be verified for critical applications.

Related Tools

Related Tools

View all tools

SVG Path Length Calculator FAQ

What is SVG Path Length Calculator?

SVG Path Length Calculator is a free developer tools tool that helps you Calculate path length for stroke-dasharray animations.

How do I use SVG Path Length Calculator?

Enter your input values, review the calculated output, and adjust inputs until you reach the result you need. The result updates in your browser.

Is SVG Path Length Calculator private?

Yes. Calculations run locally in your browser. Inputs are not uploaded to a server by default, and refreshing the page clears session data.

Does SVG Path Length Calculator require an account or installation?

No. You can use this tool directly in your browser without sign-up or software installation.

How accurate are results from SVG Path Length Calculator?

This tool applies standard formulas or deterministic processing logic for estimates. For medical, legal, tax, or investment decisions, verify with a qualified professional.

Can I save or share outputs from SVG Path Length Calculator?

You can bookmark this page and copy outputs manually. Results are not persisted in your account and are typically not embedded in the URL.

Request a New Tool
Improve This Tool