A powerful Python tool that intelligently converts Lottie animations between light and dark themes.
Preserves transparency and maintains animation quality while inverting embedded image colors.
One-click FREE theme conversion for your Lottie animations.
Live Demo · Documentation · Report Bug · Request Feature
Share Lottie Theme Converter
🌟 Pioneering intelligent theme conversion for Lottie animations. Built for designers and developers.
Tip
⭐ Star us to receive all release notifications from GitHub without delay!
📑 Table of Contents
- 🌟 Introduction
- ✨ Key Features
- 🛠️ Tech Stack
- 🚀 Getting Started
- 📖 Usage Guide
- 🎯 How It Works
- 📁 Project Structure
- 🤝 Contributing
- 📄 License
- 👥 Author
We created this intelligent Lottie theme converter to solve a common problem faced by designers and developers: seamlessly converting Lottie animations between light and dark themes while preserving transparency and animation quality.
Whether you're building modern web applications, mobile apps, or any digital interface that supports both light and dark modes, this tool ensures your Lottie animations look perfect in any theme.
Note
- Python 3.8+ required
- Only Pillow library dependency
- Works with any Lottie JSON file containing base64 images
- Preserves alpha channel transparency
| No complex setup required! Just run the script and get your themed animation. |
|---|
Tip
⭐ Star us to stay updated with new features and improvements!
Experience intelligent color processing that inverts RGB channels while preserving alpha transparency. Our algorithm ensures your animations maintain their visual quality and transparency effects.
Perfect for applications requiring both light and dark mode animations. Convert your light theme animations to dark theme versions effortlessly.
Clean, readable Python code using only the Pillow library. Easy to understand, modify, and integrate into your workflow.
Efficiently processes base64 encoded images embedded directly in Lottie JSON files without requiring external image files.
Simply place your Lottie file and run the script. Your dark theme animation will be generated instantly.
Core Technologies:
- Python 3.8+: Main programming language
- Pillow (PIL) 11.0.0: Image processing library
- JSON: Lottie animation file format
- Base64: Image encoding/decoding
Important
Ensure you have Python 3.8+ installed on your system.
1. Clone Repository
git clone https://github.com/ChanMeng666/lottie-edit.git
cd lottie-edit2. Install Dependencies
pip install -r requirements.txt3. Prepare Your Animation
Place your light theme Lottie animation file as Animation-ClickMe.json in the project directory.
4. Run Conversion
python convert_lottie.py🎉 Success! Your dark theme animation will be saved as Animation-ClickMe-dark.json.
# Install Pillow directly
pip install pillow==11.0.0
# Download the script
wget https://raw.githubusercontent.com/ChanMeng666/lottie-edit/main/convert_lottie.pyStep 1: Prepare Your Lottie File
- Ensure your Lottie JSON file contains base64 encoded images
- Save it as
Animation-ClickMe.jsonin the project directory
Step 2: Run the Conversion
python convert_lottie.pyStep 3: Get Your Result
- The converted dark theme animation will be saved as
Animation-ClickMe-dark.json - Use this file in your dark mode interface
To customize input/output filenames, modify the script:
# Change input filename
with open('your-animation.json', 'r') as f:
data = json.load(f)
# Change output filename
with open('your-animation-dark.json', 'w') as f:
json.dump(data, f)// Use in web applications
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
const animationPath = isDarkMode ?
'./animations/Animation-ClickMe-dark.json' :
'./animations/Animation-ClickMe.json';
lottie.loadAnimation({
container: element,
renderer: 'svg',
loop: true,
autoplay: true,
path: animationPath
});The conversion process follows these intelligent steps:
flowchart TD
A[Read Lottie JSON] --> B[Extract Assets]
B --> C{Contains Base64 Images?}
C -->|Yes| D[Decode Base64 to Image]
C -->|No| H[Skip Asset]
D --> E{Has Alpha Channel?}
E -->|RGBA| F[Split RGB and Alpha]
E -->|RGB| G[Direct Color Inversion]
F --> I[Invert RGB, Preserve Alpha]
G --> J[Encode Back to Base64]
I --> J
J --> K[Update JSON Asset]
H --> L[Process Next Asset]
K --> L
L --> M{More Assets?}
M -->|Yes| C
M -->|No| N[Save Dark Theme JSON]
- JSON Parsing: Load and parse the Lottie JSON file
- Asset Detection: Identify base64 encoded images in the assets array
- Image Decoding: Convert base64 strings back to image objects
- Smart Inversion:
- For RGBA images: Separate RGB and Alpha channels
- Invert RGB values:
new_value = 255 - original_value - Preserve Alpha channel unchanged
- Re-encoding: Convert processed images back to base64
- JSON Update: Replace original base64 data with inverted versions
- File Generation: Save the new dark theme JSON file
lottie-edit/
├── convert_lottie.py # Main conversion script
├── requirements.txt # Python dependencies
├── Animation-ClickMe.json # Sample light theme animation
├── Animation-ClickMe-dark.json # Generated dark theme animation
├── README.md # Project documentation
├── LICENSE # MIT license
└── CODE_OF_CONDUCT.md # Community guidelines
| File | Description | Purpose |
|---|---|---|
convert_lottie.py |
Main Python script | Handles the theme conversion logic |
requirements.txt |
Dependencies list | Specifies Pillow version requirement |
Animation-ClickMe.json |
Sample input file | Example light theme Lottie animation |
Animation-ClickMe-dark.json |
Sample output file | Generated dark theme animation |
We welcome contributions! Here's how you can help improve this project:
1. Fork & Clone:
git clone https://github.com/ChanMeng666/lottie-edit.git
cd lottie-edit2. Create Branch:
git checkout -b feature/your-feature-name3. Make Changes:
- Follow Python best practices
- Add comments for complex logic
- Test with various Lottie files
- Update documentation as needed
4. Submit PR:
- Provide clear description
- Include example files if applicable
- Ensure the script works with different animation types
Code Style:
- Follow PEP 8 Python style guidelines
- Add docstrings for functions
- Use meaningful variable names
- Include error handling
Pull Request Process:
- Update README.md if needed
- Test with multiple Lottie files
- Ensure compatibility with Pillow 11.0.0
- Request review from maintainers
Issue Reporting:
- 🐛 Bug Reports: Include Lottie file samples and error messages
- 💡 Feature Requests: Explain use case and benefits
- 📚 Documentation: Help improve our guides
- ❓ Questions: Use GitHub Discussions
This project is licensed under the MIT License - see the LICENSE file for details.
Open Source Benefits:
- ✅ Commercial use allowed
- ✅ Modification allowed
- ✅ Distribution allowed
- ✅ Private use allowed
Chan Meng Creator & Lead Developer |
Contact Information:
- 📧 Email: [email protected]
- 💼 LinkedIn: chanmeng666
- 🐦 GitHub: ChanMeng666
- 🌐 Website: chanmeng.live
Empowering designers and developers worldwide
⭐ Star us on GitHub • 📖 Read the Documentation • 🐛 Report Issues • 💡 Request Features • 🤝 Contribute
Made with ❤️ by the Lottie Theme Converter team