CodeApril 2026 · 5 min read

How to Use Lottie Animations on Your Website (2026)

Add lightweight, scalable Lottie animations to your website. Learn how to preview, customize, and embed Lottie JSON files with embed code.

Try the Lottie Player
Free, no signup
DG
Derek Giordano
Designer & Developer
In this guide
01What Is a Lottie Animation?02Why Lottie Over GIF or Video03Previewing and Customizing Animations04Embedding Lottie on Your Site
⚡ Key Takeaways
  • Add lightweight, scalable Lottie animations to your website.
  • What Is a Lottie Animation?.
  • Why Lottie Over GIF or Video.
  • Covers previewing and customizing animations.
  • Covers embedding lottie on your site.

What Is a Lottie Animation?

Lottie is a JSON-based animation format created by Airbnb's design team. It renders vector animations exported from Adobe After Effects (via the Bodymovin plugin) on web, iOS, and Android. Unlike GIFs or videos, Lottie animations are resolution-independent (they scale to any size without quality loss), tiny in file size (typically 5-50 KB compared to megabytes for equivalent GIFs), and fully controllable via JavaScript — you can pause, reverse, change speed, and respond to user interactions programmatically.

Why Lottie Over GIF or Video

File size is the primary advantage. A 5-second loading animation as a GIF might be 500 KB. The same animation as Lottie JSON is typically under 20 KB — a 25x reduction. Lottie animations render at native resolution on any screen, so they look crisp on retina displays without doubling the file size. They support transparency natively (no green-screen workarounds). They can be interactive — play on hover, scrub with scroll, respond to clicks. And they're accessible — you can add ARIA labels and respect prefers-reduced-motion media queries.

💡 Tip
Stick to animating transform and opacity for smooth 60fps performance. These properties are handled by the GPU compositor and skip expensive layout recalculations.

Previewing and Customizing Animations

The Lottie Player lets you drop a .json file and instantly preview the animation. Control playback speed (0.25x to 2x), pause on any frame, and scrub the timeline to inspect timing. The bounce mode (alternating direction) creates seamless loops for loading animations. You can find thousands of free Lottie files on LottieFiles.com — download the JSON file and drop it into the player to preview before adding it to your project.

⚠ Warning
Avoid animating width, height, top, or left. These trigger layout recalculations on every frame and can drop performance below 60fps.

Embedding Lottie on Your Site

The simplest approach is the lottie-player web component: add a script tag for @lottiefiles/lottie-player and use the lottie-player HTML element with a src attribute pointing to your JSON file. For React projects, use the @lottiefiles/react-lottie-player package. For more control, use the lottie-web library directly — it gives you access to playSegments(), setSpeed(), and frame-level control via the enterFrame event. Host the JSON file alongside your other assets — it's just a static file, no special server setup needed.

Frequently Asked Questions

Where do I get Lottie animation files?+
LottieFiles.com is the largest marketplace with thousands of free animations. You can also export from After Effects using the Bodymovin plugin, or create them in tools like Haiku, Flow, and Rive. The Lottie Player accepts any valid Lottie JSON file.
Do Lottie animations work in all browsers?+
Yes. The lottie-web renderer supports all modern browsers (Chrome, Firefox, Safari, Edge). It renders animations using SVG, Canvas, or HTML depending on the renderer option. SVG is the default and provides the best quality.
How do I reduce Lottie file size?+
Simplify paths in After Effects before exporting. Remove unused layers. Avoid raster images embedded in the animation (these inflate the JSON dramatically). Use the Lottie optimizer at LottieFiles to strip metadata. Most well-made Lottie files are naturally under 50 KB.
Try it yourself

Use the Lottie Player — free, no signup required.

⚡ Open Lottie Player