Skip to main content
GSAP Animation TutorialArticle 29

GSAP MorphSVG Tutorial: Morph One SVG Shape Into Another

Change the geometry of one SVG path into another, align points with shapeIndex, build accessible icon states and connect smooth morphs to timelines and scrolling.

GSAP MorphSVG Tutorial Morph One SVG Shape Into Another - NavTechSolution

MorphSVGPlugin answers “what geometry should this path become?” In Article #27, DrawSVG revealed a stroke. In Article #28, MotionPath moved a traveler. Here the visible source path itself changes shape.

1. What Is SVG Morphing?

SVG morphing changes vector geometry over time. A circle can become a rounded square, triangle or star because the path’s points and curves interpolate toward new path data. CSS transforms alone cannot perform true path morphing.

MorphSVG mental model comparing transforms with geometry morphing
Transforms preserve conceptual geometry; MorphSVG changes the path itself.

2. Morph vs Transform

TRANSFORM
scale / rotate

The circle remains a circle.

MORPH
geometry

The circle becomes a star.

3. DrawSVG vs MotionPath vs MorphSVG

These tools solve different problems: DrawSVG changes stroke visibility, MotionPath changes position along a route, and MorphSVG changes shape geometry.

DrawSVG reveals a path, MotionPath moves a traveler and MorphSVG changes a shape
Reveal, move and morph are separate operations that can be coordinated in a timeline.

4. Plugin Setup

The series uses GSAP 3.13.0, when MorphSVGPlugin became freely available with the GSAP package. Load the version-matched plugin once after core and register it before the article script runs.

<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/MorphSVGPlugin.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/ScrollTrigger.min.js"></script>

gsap.registerPlugin(MorphSVGPlugin, ScrollTrigger);

5. First MorphSVG Demo

Circle source ready.

6. First Morph Animation

gsap.to(source, {
  duration: 1.5,
  morphSVG: target,
  ease: "power2.inOut"
});

7. Source vs Target

SOURCEthe visible animated pathmorphSVGTARGETthe destination geometry

8. Target Visibility

The target often exists only as geometry. Keep it in the SVG with visibility="hidden" or a scoped CSS class; animate the source path and do not hide meaningful explanatory content.

9. Why Path Geometry Matters

SHAPE A
1234
SHAPE B
123

Paths contain commands, anchors and control points. MorphSVG converts data to compatible cubic curves and adds points when needed, but the original direction and arrangement still influence the journey.

10. Point Correspondence

A1A2A3A4↓ mapping ↓B1B2B3B4

11. Simple Shape Morph

12. Multi-Shape Morph

13. Morph Timeline

Timeline ready.

14. Easing and Morphing

Easing controls when interpolation happens; MorphSVG controls what geometry is interpolated. Technical scrubbing usually uses none, while a button-driven icon often feels better with power2.inOut.

15. Morph Easing Playground

CURRENT: power1.inOut

16. Understanding shapeIndex

Closed paths can begin their point sequence anywhere. shapeIndex changes which target point corresponds to the source start. It is an offset for point mapping—not simply animation direction.

17. shapeIndex Mental Model

01234source ↕ target point correspondence01234

18. Automatic shapeIndex

shapeIndex: "auto" is the current default and calculates a natural mapping. Start there. A numeric value can skip that search and lock a mapping once you have tested the result.

19. shapeIndex Playground

SHAPE INDEX: auto

20. Find the Best Morph

  1. Start with automatic mapping.
  2. Observe the full forward and reverse morph.
  3. If the shape twists, inspect path direction and correspondence.
  4. Test a small meaningful set of numeric indices.
  5. Keep the mapping that expresses the intended transition.

21. Shape Conversion

MorphSVG can internally interpret common SVG shapes. MorphSVGPlugin.convertToPath() is useful when your workflow benefits from an explicit path in the DOM.

22. Why Convert to Path?

<circle>→ convertToPath() →<path d="…">

Circles, rectangles, ellipses, lines, polygons and polylines can become path elements. Conversion is helpful, not mandatory for every morph.

23. Conversion Demo

Source element: circle.

24. Icon Morphing

Icon morphing can reinforce an interface state, but semantics must remain in the button label and ARIA state.

25. Menu to Close Demo

26. Play to Pause Demo

27. Status Icon Morph

Waiting

28. Abstract Logo-Style Morph

N</>MorphSVG concept graphic — not an official logo

29. Multi-Stage Morph

30. MorphSVG + Timeline

tl.to(shape, { morphSVG: shape2 })
  .to(shape, { rotation: 90 }, "<")
  .to(shape, { morphSVG: shape3 })
  .to(shape, { scale: 1.1 }, "<");

31. Morph + Transform

MorphSVG can change path geometry while GSAP changes x, y, scale, rotation or opacity. Keep combined movement restrained so viewers can still read the geometry change.

32. MorphSVG + DrawSVG

DRAW STROKEMORPH SHAPEACCENT DETAILS

This article does not load DrawSVGPlugin. In a combined project, load it once and coordinate separate draw and morph tweens in one timeline.

33. MorphSVG + MotionPath

TRAVEL ●DESTINATIONMORPH ★

MotionPath moves the target first; MorphSVG can change it on arrival. MotionPathPlugin is intentionally not loaded on this page.

34. MorphSVG + ScrollTrigger

gsap.to(shape, {
  morphSVG: target,
  ease: "none",
  scrollTrigger: {
    trigger: section,
    start: "top 80%",
    end: "bottom 30%",
    scrub: true
  }
});

35. Scroll-Driven Morph

0% CIRCLE50% INTERPOLATE100% STAR

36. Morph + Scrub

Without scrub, crossing the start boundary starts an ordinary tween. With scrub, scroll progress controls morph progress, including the intermediate geometry.

37. ScrollTrigger Start/End

START
top 80%
END
bottom 30%

38. Reversible Scroll Morph

A scrubbed tween naturally reverses as the reader scrolls upward. Do not create another tween for reverse scrolling.

39. Main MorphSVG Lab

GSAP MORPHSVG LAB

Design a Shape Transformation

Source
circle
Target
star
Duration
1.5s
Ease
power2.inOut
shapeIndex
auto

40. Main Lab Controls

Change one variable at a time. Target chooses geometry; duration and ease control timing; shapeIndex controls point correspondence; rotation is an ordinary transform.

41. Main Lab Status

The status row repeats the active settings in text so the experiment is not communicated through shape or motion alone.

42. Generated Code

The lab writes the equivalent scoped tween below its controls. Copy the pattern, then replace the selectors with references from your own component.

43. Lab Lifecycle

Before rebuilding the lab tween, its own tween is killed. The page never calls a global kill method and never removes another article’s ScrollTrigger.

44. Resetting SVG Geometry

The lab stores the source d value. Restart restores that exact geometry before creating a fresh tween, preventing one experiment from contaminating the next.

45. Main Mini Project

NAVTECHSOLUTION

DEVELOPMENT TRANSFORMATION

Development transformationA central shape changes through idea, design, build and deploy stages.
IDEADESIGNBUILDDEPLOY

Project ready.

46. Project Shapes

Every target is an original abstract path in the same viewBox. The visible source remains one path throughout the project.

47. Project Timeline

A single paused timeline morphs IDEA → DESIGN → BUILD → DEPLOY and updates the text stage at the same labelled positions.

48. Project Controls

Play, pause, reverse and restart operate on the same timeline, so state remains predictable and keyboard accessible.

49. Responsive SVG Morphing

ONE VIEWBOX
0 0 500 360
FLUID SVG
width: 100%
SAME GEOMETRY
desktop + mobile

50. Shape Complexity

More points mean more path calculations and more rendering work. Simplify exported artwork and avoid animating many complex full-screen morphs simultaneously.

51. Path Direction

Clockwise and counter-clockwise paths can map differently. If automatic mapping twists, inspect direction before forcing an arbitrary large shapeIndex.

52. Common Morph Problems

TWISTING

Check direction and shapeIndex.

DOUBLE SHAPE

Hide the target geometry.

JUMPING RESET

Restore the original d value.

NO ANIMATION

Confirm plugin load and registration.

53. Performance

  • Keep visible path geometry as simple as the design allows.
  • Reuse one source instead of layering duplicate visible targets.
  • Scope tweens and store references for cleanup.
  • Use a numeric shapeIndex only after testing it.

54. Mobile Strategy

Let controls wrap, preserve a stable viewBox, keep buttons at least touch-friendly height and avoid scroll-pinning the main lab on small screens.

55. Reduced Motion

const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
if (reduced) tween.progress(1).pause();

56. Accessibility

Use real buttons, visible focus, meaningful SVG labels and live text status. A morph may decorate or reinforce state, but must not be the only way a user learns that state.

57. Progressive Enhancement

Before JavaScript loads, the source SVG and every explanation remain visible. Target geometry is hidden only because it is implementation data.

58. Common Mistakes

  1. Loading GSAP or MorphSVGPlugin twice.
  2. Animating the hidden target instead of the visible source.
  3. Calling shapeIndex “direction”.
  4. Using unscoped selectors across several demos.
  5. Recreating ScrollTrigger or ScrollSmoother globally.
  6. Relying on motion alone for status.

59. Debugging Checklist

✓ GSAP core loaded once✓ MorphSVGPlugin loaded once✓ Versions match 3.13.0✓ Plugin registered before use✓ Source is the tween target✓ Target selector resolves✓ Source and target share a coordinate system✓ Target is not visibly duplicated✓ Reduced motion has a final state✓ Only owned tweens are killed

60. Quick Reference

GoalPattern
Basic morphmorphSVG: target
Point mapping{ shape: target, shapeIndex: "auto" }
Convert primitiveMorphSVGPlugin.convertToPath(circle)
Scroll controlscrollTrigger: { scrub: true }
Reversetween.reverse()

61. Cheat Sheet Graphic

GSAP MorphSVG cheat sheet with target, shapeIndex, convertToPath, timeline and ScrollTrigger
Core MorphSVG patterns for a static PHP and vanilla JavaScript project.

62. Final Mental Model

START SHAPEMORPH GEOMETRYEND SHAPEGSAP controls timing. MorphSVGPlugin controls path interpolation.

63. Blog #30 Preview

Coming next

GSAP Text Animation Tutorial

Next we will animate readable text with responsible splitting, sequencing, accessibility and reduced-motion fallbacks. No link is added until Article #30 exists.

Frequently Asked Questions

What is GSAP MorphSVGPlugin?

MorphSVGPlugin animates the geometry of an SVG path so one vector shape becomes another.

How do I register MorphSVGPlugin?

Load GSAP core, load the matching MorphSVGPlugin file, then call gsap.registerPlugin(MorphSVGPlugin).

What is the difference between transform and morph?

A transform moves, rotates or scales the existing geometry; a morph changes the geometry itself.

Can MorphSVG morph paths with different point counts?

Yes. MorphSVG converts path data to cubic curves and adds points where necessary to create compatible geometry.

What is shapeIndex?

shapeIndex influences how the starting points of closed source and target paths correspond during a morph.

What does shapeIndex auto do?

The default automatic mode calculates a point mapping intended to avoid unnecessary twisting.

Can MorphSVG convert circles and rectangles to paths?

Yes. MorphSVGPlugin.convertToPath() can convert common SVG primitives into path elements.

Should the target path be visible?

No. A target can stay hidden and provide geometry while the source path remains the animated visible element.

Can MorphSVG be used in a GSAP timeline?

Yes. A timeline can sequence multiple target shapes and coordinate normal transforms or interface changes.

Can MorphSVG work with ScrollTrigger?

Yes. ScrollTrigger can start a morph or map scroll progress to it with scrub.

Can a MorphSVG tween reverse?

Yes. Reverse the tween or timeline to interpolate back toward its previous geometry.

Does MorphSVG work on a static PHP website?

Yes. PHP renders the SVG markup and ordinary browser JavaScript runs GSAP and MorphSVGPlugin.

How do I make SVG morphing responsive?

Use a stable SVG viewBox, responsive CSS sizing and paths that share the same coordinate system.

How should reduced motion be handled?

Skip animated interpolation and present the final meaningful state immediately when reduced motion is preferred.

Why does an SVG morph twist?

The paths may have unsuitable point correspondence, direction or starting points; automatic mapping or a tested shapeIndex can help.

Is MorphSVGPlugin free?

MorphSVGPlugin is available with GSAP 3.13 and later; this tutorial loads the version-matched 3.13.0 browser files.