English | [简体中文](./README.md)
# LeaferJS: An Easy-to-Use Canvas Engine
Build interactive, editable graphics apps with ease — The Infinite Canvas Engine for the AI Era
[Everyone can create with AI Skills](https://www.leaferjs.com/ai/)
Official Website: [leaferjs.com](https://www.leaferjs.com)
Open Forest: [leafer.pro](https://www.leafer.pro)
PxGrow: [pxgrow.com](https://www.pxgrow.com)
**👉 A Canvas engine that can handle 1 million graphics in the browser**
**👉 A Canvas core capable of building Figma-level editors**
Extreme Performance · Ultra-Low Memory · DOM-like API · Graphic Editing · Cross-Platform · Zero Dependencies · Lightweight (70KB min+gzip)
[](https://www.npmjs.com/package/@leafer-ui/draw)
[](https://github.com/leaferjs/leafer-ui/stargazers)
[](https://github.com/leaferjs/leafer-ui/releases)
[](https://github.com/leaferjs/leafer-ui/blob/main/LICENSE)
## 🧐 Why Choose LeaferJS?
In Web graphics development, developers often face a trade-off between **performance and usability**.
**LeaferJS aims to eliminate this compromise.** Rebuilt from the ground up, it not only pushes the limits of Web rendering and interaction performance, but also pursues ultimate simplicity in developer experience. It is a standardized engine designed for productivity tools handling **large-scale, high-density, and massive-layer graphics**.
## 🏗️ Why an Infinite Canvas Engine for the AI Era?
With the explosion of AI-generated content, the challenge for graphics engines has shifted from **“how to render”** to **“how to organize and refine”**:
- **⚡ Extreme Capacity:** Handles millions of interactive layers smoothly, perfectly accommodating massive AI-generated fragments.
- **🤖 Semantic Editing:** A structured scene tree allows AI to manipulate graphics like the DOM, enabling true AI collaborative workflows.
- **🛠️ Native Editor:** Built-in Editor plugin enables one-click access to industrial-grade editing features such as rotation, scaling, and multi-selection for AI-generated content.
[Skills](https://www.leaferjs.com/ai/#start) | [MCP](https://context7.com/leaferjs/ai-docs?tab=skills) | [Ask AI](https://context7.com/leaferjs/ai-docs?tab=chat)
## 🎨 Use Cases
With its extreme performance and standardized capabilities, LeaferJS is an ideal foundation for:
- 🤖 **AI Applications:** Infinite AI canvas, AI design tools, generative UI interactions.
- 🛠️ **Productivity Tools:** Graphic editors, online design platforms (Figma/Canva-like), whiteboards, low-code engines.
- 📊 **Industrial Visualization:** Large-scale node systems, flowcharts, asset monitoring, massive topology diagrams.
- 🎬 **Digital Content Generation:** Batch image/poster generation, short video frame rendering (Node.js), interactive H5.
- 🎮 **Interactive Applications:** Lightweight games, brand interactive apps, high-frequency data dashboards.
## 🔥 Performance
LeaferJS pushes the ceiling of Web graphics processing by approximately **10x**.
| Test (1M Interactive Rectangles) | Traditional Canvas Libraries | **LeaferJS** | Improvement |
| :------------------------------- | :--------------------------- | :----------- | :---------------- |
| **Initial Render Time** | ~9–15 seconds | **1.28s** | **~8x faster 🎉** |
| **Memory Usage** | ~2-4GB (may crash browser) | **320MB** | **~8x lower** |
| **Drag FPS (single element)** | 0–4 FPS | **60 FPS** | **~15x faster** |
Test environment: 2K laptop screen / Chrome V143.0. Results are for reference only; actual performance depends on hardware.
[Performance Details](https://www.leaferjs.com/#performance) | [Benchmark](https://benchmark.leaferjs.com/leafer/)
## ⚡️ Core Capabilities
- **🎨 Powerful Graphics System:** Complete scene tree supporting vector graphics, SVG paths, and pixel operations.
- **🧠 Ultra-Fast Interaction:** Native support for drag, zoom, multi-touch, and millisecond-level hit testing.
- **🛠️ Built-in Editor Support:** Integrated **Editor plugin** enabling **scale, rotate, move, multi-select** with one click.
- **🧩 Modern Layout Engine:** Rare native **Flexbox layout** support in a Canvas engine — as natural as writing HTML.
- **🎬 State-Driven Animation:** Built-in high-performance transitions and path animations for smooth dynamic interactions.
- **🌍 Cross-Platform:** One codebase runs seamlessly on Web, Node.js, WeChat Mini Programs, and mobile H5.
[Full Feature List](https://www.leaferjs.com/#different) | [Live Examples](https://www.leaferjs.com/examples/)
## 🛠️ Quick Start
```sh
npm install leafer-ui
# When using plugins, it is recommended to install core packages together
# to avoid version mismatch issues
npm install leafer-ui @leafer-ui/core @leafer-ui/draw
```
```ts
import { Leafer, Rect } from 'leafer-ui'
// Create an interactive app that adapts to the window
const leafer = new Leafer({ view: window })
// Create a draggable rectangle
const rect = new Rect({
x: 100,
y: 100,
width: 200,
height: 200,
fill: '#32cd79',
draggable: true,
})
leafer.add(rect)
```
[Run Online Example](https://www.leaferjs.com/examples/#official%2Fstart%2Fcreate.ts) | [Editor Example](https://www.leaferjs.com/examples/#official%2Fplugin%2Feditor%2Fframe%2Ftransparent.ts)
## 💼 Commercial Support & Sustainability
There is a significant gap between “an engine” and “a mature product.” To ensure long-term maintenance of the open-source engine and help enterprises overcome complex development challenges, we’ve built a transparent and sustainable ecosystem:
- **LeaferJS is Permanently Open Source (MIT):** The core features and essential plugins will always remain open source and freely available, meeting the needs of the vast majority of projects. Developers can rely on a secure, controllable, and sustainable technology choice without worrying that core capabilities will become commercially restricted.
- **PxGrow Provides Optional Commercial Plugins:** Focused on solving complex challenges in **industrial-grade applications**, PxGrow offers professional editor suites, and performance optimization capabilities, helping enterprises save months or even years of development time.
- **A Virtuous Cycle with a Long-Term Vision:** Developers benefit from open source, enterprises gain efficiency through commercial capabilities, and commercial support continuously drives the growth and innovation of LeaferJS—creating an open, transparent, and sustainable ecosystem.
## LeaferJS Repository Overview
| Repository | Description | Link |
| :------------ | :------------------------------- | :---------------------------------------------- |
| **LeaferJS** | Main integration repo (runnable) | [GitHub](https://github.com/leaferjs/LeaferJS) |
| **leafer** | Core engine | [GitHub](https://github.com/leaferjs/leafer) |
| **leafer-ui** | UI layer | [GitHub](https://github.com/leaferjs/leafer-ui) |
| **leafer-in** | Official plugins | [GitHub](https://github.com/leaferjs/leafer-in) |
| **leafer-x** | Community plugins showcase | [GitHub](https://github.com/leaferjs/leafer-x) |
| **test** | Automated testing | [GitHub](https://github.com/leaferjs/test) |
| **code** | Example code | [GitHub](https://github.com/leaferjs/code) |
| **docs** | Documentation | [GitHub](https://github.com/leaferjs/docs) |
## 🌟 Five Years of Dedication, Staying True to Our Vision
LeaferJS [started in 2021](https://www.leaferjs.com/ui/blog/2023-06-28.html) and is an original open-source graphics engine that has been continuously developed and refined for over five years. We are committed to standardizing the foundations of graphics systems, allowing developers to focus on product creativity rather than underlying implementations.
**If you support original innovation, please give us a Star!**
- 🌟 **Star the Repository:** Your recognition means a lot to us.
- 🐞 **Submit Feedback:** Every issue is an opportunity for us to improve.
- 🤝 **Join the Community:** Explore the limits of Web graphics technology with fellow developers.
## Contributing
When you use LeaferJS, you become part of this vibrant community — stepping into a growing “tech castle.” Only through collective participation can it truly flourish.
[Code of Conduct](https://github.com/leaferjs/leafer-ui/blob/main/contributor/CODE_OF_CONDUCT.md)
[Commit Convention](https://github.com/leaferjs/leafer-ui/blob/main/contributor/COMMIT_CONVENTION.md)
[How to Ask Questions the Smart Way](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md#%E6%8F%90%E9%97%AE%E7%9A%84%E6%99%BA%E6%85%A7)
## Thanks to Our Contributors
[Every creator who has participated in the Open Source Forest](https://www.leafer.pro/#creator)
[Every community member who has contributed code](https://github.com/leaferjs/leafer-ui/graphs/contributors)
[Early community members who helped build the ecosystem](https://www.leaferjs.com/ui/contribute/)
## Thanks to Our Sponsors
[Every user who has supported us through sponsorship](https://www.leaferjs.com/#footer-sponsor)
## License
MIT License — free to use, including for commercial applications.
Copyright © 2023-present Chao (Leafer) Wan