Back to all articles

Createing SVG animation with Lottie

Designers often face the fact that if they create a cool icon / illustration on the site, it’s important to animate it exactly as it was intended. Many are afraid of the process itself, how can it be implemented independently without the involvement of a front-end specialist?

In this article you’ll find a simple example of how to animate a vector image on the web, which will be played by all modern browsers.

Requirements of programs and plugins: Sketch / Illustrator, Sketch2AE (plugin for transferring from Sketch 51.2 to After Effects), After Effects, Lottie (library for playing animation), Bodymovin (plugin for After Effects)

The structure of the article:

  1. Create a simple object to understand the principle of operation;
  2. Animate the shape in Adobe After Effects, a quick walkthrough;
  3. What is Lottie and Bodymovin, and how they work;
  4. Transfer the archive with files to the frontend developer for posting on the site;
  5. Confines.

Create a simple figure to understand how it works

Go to the Sketch / Illustrator and create the desired image. For clarity and ease of understanding, I’ll show you the whole process really simply. I prefer to work in Sketch, so I’ll show the further process using this program.

Create a rectangle:

Select the artboard with the file and the menu in the Plugins section, find the Sketch2AE and copy to the clipboard:

Next, go to the After Effects to create a project and enter the size of the composition so that it matches the size of your artboard (I took 800x600):

After you have created a project, on the right in the side menu you will see the Sketch2AE plugin, in which you need to select the left red block:

And paste the copied code (Cmnd/Ctrl + V)

After that, your artboard with the image displays on the screen:

There are two ways to import illustration into After Effects:

- Directly through Illustrator - drag and drop the *.ai file format into the After Effects project. All drawn shapes that will be animated need to be made layers For convenience, it is desirable to rename the layers so as not to be confused (in particular, this applies to large and complex animations);
- Via Sketch, using the Sketch2EA plugin (the site has a detailed guide on how to install it);

More detailed information about how to prepare the layout for transfer to After Effects, you can find on Youtube.

Animation of a figure in After Effects, a quick walkthrough

After we managed to transfer our layout with the image in After Effects, let's proceed to the animation. I will show you how to rotate an object and change its transparency.

Let's start by turning 90 degrees. Expand layer properties and find Rotation and Opacity there. At the initial position of the timeline, we set 0 degrees and 100% opacity, we fix them with the key, using the icon to the left of the properties (as a stopwatch), then shift the values on the timeline to 01: 00f and set the rotation properties to 90 degrees and change the transparency 30-40%:

To make the object return to its original position, copy the initial keys in the timeline and set them at the end point, until which it will return to the initial position:

Moreover, you can adjust the smoothness of your animation, using ising. Select all the keys on the timeline and click the right mouse button, then select the appropriate smoothness (I stopped at Easy Ease):

Here's what we got (there will be a video / gif here):

What are Lottie and Bodymovin

Thus, the main part of the work we’ve done, we just need to figure out how to still make our illustration work. We will understand the plugins that will help us in this.

Lottieis an iOS, Android, and React Native library that renders After Effects animations in real time, allowing apps to use animations as easily as they use static images.

Bodymovinis a plugin for After Effects that can export animation in json data format for Lottie to use.

Here is detailed and accessible description of how to connect a library that will play the animation:


And we will continue to prepare our file for further work. Having finished with animation of our object, we switch to the tab Window – Extensions – Bodymovin:

Select our file and set the path where the *.json file will be saved:

Then in the settings we remove the Glyphs checkbox (it is needed only when there are fonts in our layout, which it automatically translates into curves), and set the Demo to be able to see the work in the browser:

And start rendering:


Transfer archive file frontend developer to place on the site

Voila! Now you have a *.json file that you only need to pass to the developer. Together with him, you give him links describing how to connect a library that will play the animation:



This method has a number of limitations in the work, the main ones:

  1. - work with gradients (problems may arise);
  2. - works only with vector images (although it can pull png and jpg)
  3. - does not support any effects, therefore you need to create your animation with simple methods;
  4. - use Alpha matte and Alpha inverted matte as little as possible (it is better to use masks instead of them);
  5. - use as few points as possible in masks and keyframes on such masks;

Detailed restrictions can be found on the Lottie and Bodymovin official website.

final results:

json file

html result:


Thanks for reading!

I hope my experience will help you in promoting your design activities.