How to Query Relationships in a .lottie File

Use dotlottie-io's cross-reference query methods to find which animations use a theme, state machine, or asset.

How to Query Relationships in a .lottie File

dotlottie-io exposes four query methods — available on both DotLottie and DotLottieReader — for inspecting how content in a package references other content. dotlottie-js has no equivalent to these.

Which animations use a theme?

dotlottie.animationsUsingTheme("dark"); // → string[]

Returns animation IDs whose manifest entry references the given theme, via initialTheme or the themes array.

Which animations does a state machine control?

dotlottie.animationsUsedByStateMachine("sm-button"); // → string[]

Returns every unique animation ID referenced by a PlaybackState entry in the given state machine.

What assets does an animation reference?

dotlottie.assetReferences("hero"); // → { images: string[], fonts: string[], audio: string[] }

Returns categorized, external asset filenames referenced by the animation's Lottie JSON.

Which animations use a given asset?

dotlottie.animationsUsingAsset("logo.png"); // → string[]

The reverse lookup of assetReferences — useful for auditing.

Worked example: finding unused assets before shipping

const { DotLottie } = require("@lottiefiles/dotlottie-io");

const dl = DotLottie.fromFile("package.lottie");

const unusedImages = dl.imageFilenames().filter((filename) => dl.animationsUsingAsset(filename).length === 0);

const unusedAudio = dl.audioFilenames().filter((filename) => dl.animationsUsingAsset(filename).length === 0);

if (unusedImages.length || unusedAudio.length) {
  console.warn("Unused assets found:", { unusedImages, unusedAudio });
}

A note on DotLottieReader

The same four methods exist on DotLottieReader, with different costs: animationsUsingTheme reads only the manifest (free), while animationsUsedByStateMachine and assetReferences each read one ZIP entry, and animationsUsingAsset reads every animation entry (O(n)). If you're calling animationsUsingAsset repeatedly, load the file with DotLottie instead — it's already fully parsed in memory.

Last updated: August 5, 2026 at 11:47 AMEdit this page