npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

lottie-web-parser

v2.1.0

Published

Utility functions for parsing color & text information from lottie-web JSONs.

Downloads

1,088

Readme

lottie-web-parser

Utility functions for parsing color & text information from lottie-web JSONs.

Motivation

lottie-web is a great way of rendering After Effects animations natively on the Web. These animations are exported from After Effects as JSON files that hold all animation data: layers, shapes, colors, keyframes etc.

At Flixier we wanted to build an editor for these lottie animations, so you can customize yours as you please. Demo below:

The hardest part was understanding the JSON format and parsing/modifying it in such a way that

  1. it's still valid
  2. it produces the result we want.

Features

  • determine if the lottie has text information or not
  • find and replace all shape colors (fill or stroke), including those that have the color specified as an JavaScript expression
  • parse texts

Installation

$ npm install lottie-web-parser

Then, import this package into your app (you might need a build tool like webpack if wanting to run in the browser.

API

hasTextLayers(animaitonData): boolean

Checks if the animation data passed as argument has text information or not.

import LottieWebParser from 'lottie-web-parser';
import animationData from './data.js';

LottieWebParser.hasTextLayers();

parseColors(animationData): Array<{ name: string, path: string, color: number[] }>

Parses the animationData and returns an array of color information, including the name of the shape/layer.

import LottieWebParser from 'lottie-web-parser';
import animationData from './data.js';

let colorInfo = LottieWebParser.parseColors(animationData);
console.log(colorInfo);

replaceColor(rgba, path, animationData)

Params:

  • rgba: Array
  • path: string
  • animationData: JSON object

Modifies the animationData in place, by replacing the color value found at that path after it adjusts the values:

  • if the current color values are in [0-1] then it will normalize to this interval
  • otherwise it will use the real values
import LottieWebParser from 'lottie-web-parser';
import animationData from './data.js';

let colorInfo = LottieWebParser.parseColors(animationData);
LottieWebParser.replaceColor([255, 0, 0, 1], colorInfo[0].path, animationData);

replaceKeyframeColor(rgba, path, animationData)

Params:

  • rgba: Array
  • path: string
  • animationData: JSON object

Modifies the animation data in place, by replacing the value found at that path. Similar to replaceColor above, it adjusts the values.

import LottieWebParser from 'lottie-web-parser';
import animationData from './data.js';

let path = 'layers.5.shapes.2.c.k.0';
LottieWebParser.replaceColor([255, 0, 0, 1], path, animationData);

getKeyframeColors(path, animationData)

Params:

  • path: string
  • animationData: JSON object

Returns the color values at path. If the values are in [0, 1] interval it will adjust them to the RGB interval [0-255].

parseTexts(animationData) : Array<{name: string, text: string, fontFamily: string, fontName: string, path: string}>

Parses the animationData and returns an array of text information.

import LottieWebParser from 'lottie-web-parser';
import animationData from './data.js';

if (LottieWebParser.hasTextLayers(animationData)) {
    let textInfo = LottieWebParser.parseTexts(animationData);
    console.log(textInfo);
}
// Example response
[{
    name: 't1',
    text: 'Type something here',
    fontName: 'Roboto-Black',
    fontFamily: 'Roboto',
    path: `layers.2.t.d.k.0.s.t`
}]

PS: special thanks to sonaye/lottie-editor, whose code was the foundation of this package.