DevTools Logo

SVG Path Morpher

SVG Path Morpher

Interpolate two SVG paths and generate SMIL or CSS animation code

Runs in your browser
Try an example

Path data

1 line · 121 chars · 1 line · 33 chars

Interpolated path

4 cubic segments · 1 sub-path
CSS animation of the d property is not supported in every browser (Safari in particular). SMIL is the more portable export.

Examples

Midpoint of two lines

Input
interpolatePaths(normalizePaths("M 0 0 L 10 0", "M 10 10 L 20 10").from, normalizePaths("M 0 0 L 10 0", "M 10 10 L 20 10").to, 0.5)
Output
"M 5.000 5.000 ..."

Start points (0,0) and (10,10) average to (5,5) with three-decimal formatting.

Circle to square

Input
generateSvgAnimation(SVG_MORPH_EXAMPLES.circle, SVG_MORPH_EXAMPLES.square)
Output
{ smil: "<path ...>", css: "@keyframes svg-path-morph ..." }

Four cubic segments normalize on both sides and produce stable SMIL plus CSS output.

About this tool

SVG Path Morpher interpolates between two path strings with normalizePaths(from, to) plus interpolatePaths(from, to, t): parseSvgPath converts M, L, C, Q, and Z commands into cubic segments, pads the shorter side by repeating its last segment, and lerps every coordinate at parameter t.

Closed paths round-trip through Z: a Z command closes the subpath with a cubic back to the subpath start and sets closed true, so interpolated output ends with " Z" whenever either input was closed.

Only the five supported commands parse — anything else (e.g. A arcs) throws "Unsupported SVG path command", and generateSvgAnimation emits deterministic SMIL plus CSS @keyframes svg-path-morph output for the same inputs.

How to use this tool

  1. Provide two paths

    Pass path strings starting with M to normalizePaths — mismatched segment counts are padded automatically.

  2. Interpolate at t

    Call interpolatePaths with t in [0, 1]; 0.5 gives the exact midpoint of every coordinate.

  3. Keep Z for closed shapes

    End closed shapes with Z so circle-to-square morphs stay closed through the animation.

  4. Export the animation

    Use generateSvgAnimation for ready-to-paste SMIL values and CSS d: path() keyframes.

Use cases

Animating icon transitions

Morph play-to-pause or circle-to-square icons with matching closed-path keyframes.

Prototyping logo morphs

Preview midpoint shapes between two wordmarks before committing to hand-tuned animation.

Teaching Bézier conversion

Show how lines and quadratics expand into cubics for a shared interpolation space.

Common mistakes

Mistake:Interpolating without normalizing first.

Fix:interpolatePaths throws unless segment counts match — always pass normalizePaths output.

Mistake:Feeding arc (A) commands.

Fix:Arcs are unsupported by design; convert them to C curves in a vector editor first.

Frequently asked questions

What does this tool do?

It morphs SVG shapes with normalizePaths plus interpolatePaths, and exports animations with generateSvgAnimation (SMIL values plus CSS @keyframes svg-path-morph).

What happens with different command counts?

The shorter path is padded by repeating its last cubic segment, so both sides end with equal segment counts before lerping.

Is my artwork uploaded or stored?

No. Path parsing, normalization, and interpolation run fully client-side.

Why did my path throw?

Only M, L, C, Q, and Z parse — arcs (A) throw Unsupported SVG path command, and empty or segment-free paths throw as well.

References & standards