Command line · Free · MIT
Optimize Lottie files from the command line
tinylottie is the TinyLottie engine as a CLI. Run it on one file, a whole folder of animations, or in CI to stop unoptimized animations from being merged. Everything runs on your machine: no uploads, no telemetry.
npx tinylottie animation.json # → animation.min.json npx tinylottie animation.json -f lottie # → animation.min.lottie npx tinylottie src/assets --in-place # every Lottie in a folder
What it does
- Removes editor-only metadata (
nm,mn,cl, defaulthd: false). - Rounds coordinates to 3 decimals (configurable with
--precision). - Re-encodes embedded PNG/JPEG/GIF images as WebP when that makes them smaller (uses the optional
sharppackage). - Converts between Lottie JSON and dotLottie with
--format. - Never makes a file bigger: if it can't beat the original, the original bytes are kept.
Block heavy animations in CI
Add one step to a GitHub Actions workflow. The job fails when any animation in the folder could shrink by more than 10%, and the log shows which files and by how much.
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npx tinylottie@latest public/animations --check --threshold 10Options
| -o, --out-dir <dir> | Write results to a folder (default: next to the input as <name>.min.<ext>) |
| --in-place | Overwrite the input files |
| -f, --format json|lottie | Output format (default: same as input) |
| -p, --precision <n> | Decimal places to keep (default 3) |
| -q, --quality <n> | WebP quality for embedded images (default 80) |
| --no-images | Leave embedded images untouched |
| --check | CI mode: write nothing, exit 1 if any file can shrink by more than --threshold % |
| --threshold <n> | Percent used by --check (default 10) |
| --json | Machine-readable report |
Folders are scanned recursively for .json and .lottie files (skipping node_modules and dot-folders). JSON files that aren't Lottie animations, like package.json, are ignored.
Limits
The CLI is free for files up to 3 MB and needs Node.js 18 or newer. Larger files are skipped with a notice. For files up to 50 MB, use the browser compressor with Lifetime PRO.