HTML to Lottie Converter (and Lottie to HTML)
Turn an HTML, CSS or JavaScript animation (GSAP, requestAnimationFrame, element.animate) into a Lottie JSON or .lottie file, or convert a Lottie animation back into plain HTML with CSS @keyframes. Compare both side by side before you download.
@keyframes and get a Lottie .json or .lottie file, or drop in a Lottie file and get HTML with pure CSS animation (no JavaScript player). Everything runs in your browser; your code is rendered in a locked sandbox and never uploaded.
Separate CSS (optional)
Stage: a CSS selector such as .stage. Left empty, a single top-level element becomes the canvas, otherwise the whole page.
How to use HTML to Lottie Converter
-
1
Pick a direction. Choose HTML → Lottie to make a Lottie from a web animation, or Lottie → HTML to turn a Lottie file into code.
-
2
Paste code or upload a file. Paste HTML with its CSS, or upload .html, .css and .svg files. On the other side, paste Lottie JSON or upload a .json or .lottie file.
-
3
Set the canvas and frame rate. Leave Stage element empty to use your single top-level element as the canvas, or type a selector like .stage. Pick 24, 30 or 60 fps.
-
4
Convert and compare. Click Convert. The original and the result play next to each other, with a list of anything that could not be converted exactly.
-
5
Copy or download. Download the Lottie as .json or .lottie, or the converted page as .html, or copy the CSS, markup or React component.
By Mohit Khatri · Last updated
Learn more about HTML to Lottie Converter
Direct Answer: A Lottie file is a JSON description of a vector animation: a canvas size (w, h), a frame rate (fr), a start and end frame (ip, op) and a list of layers. Players such as lottie-web, lottie-android and lottie-ios redraw the layers at every frame. The format began as the export of the Bodymovin plugin for After Effects and is now an open standard from the Lottie Animation Community (spec 1.0).
Each layer has a transform (ks) with an anchor point, position, scale in percent, rotation in degrees and opacity from 0 to 100. A property is either static ({"a":0,"k":value}) or a list of keyframes, each with a frame t, a value s and easing handles o and i. Those handles are exactly a CSS cubic-bezier(), which is why CSS animation and Lottie translate so well into each other.
Layer types: 0 precomposition, 1 solid colour, 2 image, 3 null (an invisible parent), 4 shape, 5 text. The first layer in the list is drawn on top.
Direct Answer: The tool lets your browser do the hard part. It renders your HTML in a hidden, sandboxed frame, reads each element's box and computed styles, and reads every running CSS animation through the Web Animations API, so units, shorthands, @keyframes and easing are resolved exactly as the browser sees them.
- Layout and nesting: each visible element becomes a shape layer (a rectangle with its background, border and corner radius). Child elements are parented to their parent's layer, and
transform-originbecomes the anchor point. - Transforms:
transformand the individualtranslate,rotateandscaleproperties are decomposed into Lottie position, rotation and scale. Full turns such asrotate(720deg)are kept. - Opacity: CSS opacity multiplies down to children, but Lottie parenting does not pass opacity on, so ancestor opacity is multiplied into each child layer.
- Timing: delays, iteration counts,
alternatedirections and fill modes are unrolled into keyframes.steps()becomes hold keyframes. The Lottie length is chosen so loops of different lengths end together.
Direct Answer: Every Lottie layer becomes an absolutely positioned element. Its position, rotation, scale and anchor point map to the CSS translate, rotate, scale and transform properties, which CSS applies in the same order as Lottie, and each animated property becomes its own @keyframes rule with the original cubic-bezier easing.
- Shapes become inline SVG paths, rectangles and ellipses with their fills, strokes and gradients. Trim paths become animated stroke dashes, and shape morphs use the CSS
d: path()property. - Parenting becomes nested wrappers that repeat the parent's motion, so a child never inherits its parent's opacity by mistake.
- In and out points become stepped opacity, and precompositions are clipped to their size, as lottie-web does.
- Masks become CSS
clip-path: path().
Track mattes, After Effects expressions, layer effects, repeaters and per-letter text animators have no clean CSS equivalent. The tool lists them and offers the exact player embed instead.
Direct Answer: We compare screenshots of the original and the converted animation at several moments of the timeline in Chromium. A pixel counts as different when any colour channel differs by more than 48 of 255.
| Test | What it covers | Pixels that differ |
|---|---|---|
| HTML → Lottie, shapes | Spinner with colour change, bouncing ball with alternate easing, nested orbit, steps(), inline SVG | under 0.3% |
| HTML → Lottie, text | Gradient card with a delayed slide-in and two lines of text | under 3% (text anti-aliasing) |
| Lottie → HTML, After Effects exports | Character and logo animations from the lottie-web test suite with parenting, precomps, masks and shape morphs | 0–3% for files without mattes or expressions |
Files that rely on track mattes, expressions or effects differ more, and the tool tells you so before you download.
Direct Answer: Use CSS animation for small interface motion that lives on one website. Use Lottie when the same animation must play in iOS, Android, React Native, Flutter and the web, or when a designer will edit it later.
| CSS animation | Lottie | |
|---|---|---|
| Runs on | Browsers | Web, iOS, Android, React Native, Flutter, Windows |
| Needs a player | No | Yes (lottie-web is about 250 KB minified) |
| Edited in | Code editor | After Effects, LottieFiles, Lottielab, Figma plugins |
| Control from code | Classes, CSS variables | play, pause, seek, segments, speed |
- Wrap the animation in one element (for example
<div class="stage">) with a fixed width and height. It becomes the Lottie canvas. - Animate transforms and opacity rather than
left/topor margins. They map one to one onto Lottie layer properties. - Avoid blur filters and canvas drawings. Shapes, gradients, ::before/::after and SVG convert; pixels drawn on a canvas do not.
- Embed images as data: URLs or keep them on the same site, so the browser is allowed to copy them into the file.
- Convert text to outlines when the exact font matters. Lottie text uses the fonts installed where it plays.
- Need code from a design instead? Try the HTML to Flutter converter, tidy the generated CSS with the CSS Minifier, or check a Lottie file with the JSON Formatter.
- Lottie Animation Format specification 1.0 — the open standard maintained by the Lottie Animation Community.
- lottie-web — the reference web player used for the previews and the player embed.
- dotLottie — the zipped .lottie container format.
- MDN: CSS animations and Web Animations API.
Frequently Asked Questions
How do I convert an HTML animation to Lottie?
@keyframes animation the browser finds, and writes the same motion as Lottie layers and keyframes. Download the result as .json or .lottie.
Which CSS properties can be converted to Lottie?
transform, translate, rotate, scale), transform-origin, opacity, background-color, linear and radial gradients (including stripes and dot patterns made with repeating or tiled gradients), border colour and width (also a different colour per side, as in ring spinners), border-radius, box-shadow rings and soft shadows, width/height, text, images, ::before/::after pseudo-elements and inline SVG. Shapes inside an SVG are animated too: CSS on SVG elements, SMIL (<animate>) and stroke-dashoffset "line drawing" become Lottie path, colour and trim-path keyframes. Timing keeps animation-delay, iteration count, alternate/reverse direction, fill mode, cubic-bezier easing and steps().
What can't be converted from CSS to Lottie?
filter (blur is approximated only for shadows), clip-path, blend modes, 3D transforms or skew. <canvas> and WebGL drawings are pixels, not shapes, so they can't be recorded, and a stroke with several dashes is drawn solid. If a script hides or removes the whole animation (like a page loader that dismisses itself), the tool converts the animation from before that point and tells you. The tool lists everything it skipped, so you know why a frame differs.
Can it convert JavaScript animations like GSAP or requestAnimationFrame?
<script>). The page runs with a controlled clock: the tool steps requestAnimationFrame, timers, Date and performance.now() one frame at a time, records every element's position, rotation, scale, opacity, colour, size and text, and keeps only the keyframes needed. GSAP, anime.js, element.animate(), CSS transitions started by scripts and hand-written loops all work. Libraries can be loaded from cdnjs, jsDelivr or unpkg.
Is it safe to run pasted JavaScript in the converter?
fetch, XHR, WebSockets, workers, forms and external images; only script files from cdnjs, jsDelivr and unpkg may load. Anything blocked is listed in the warnings.
Can I convert a Lottie file to HTML and CSS without a JavaScript player?
@keyframes rule with the original easing, so the animation plays with no script at all. Shapes are drawn as inline SVG.