canvg

在画布(Canvas)上解析和渲染 SVG 的 JavaScript。「Javascript SVG parser and renderer on Canvas」

Github stars Tracking Chart

canvg

NPM version
Dependencies status
Build status
Coverage status

JavaScript SVG parser and renderer on Canvas. It takes the URL to the SVG file or the text of the SVG file, parses it in JavaScript and renders the result on Canvas. It also can be used to rasterize SVG images.

Quickstart
  •  
Docs
  •  
Demo

Quickstart

Install this library using your favorite package manager:

pnpm add canvg
# or
yarn add canvg
# or
npm i canvg

Then, just import Canvg and use it:

import { Canvg } from 'canvg';

let v = null;

window.onload = async () => {
  const canvas = document.querySelector('canvas');
  const ctx = canvas.getContext('2d');

  v = await Canvg.from(ctx, './svgs/1.svg');

  // Start SVG rendering with animations and mouse handling.
  v.start();
};

window.onbeforeunload = () => {
  v.stop();
};

Description of all exports you can find in Documentation.

Docs

What's implemented?

The end goal is everything from the SVG spec. The majority of the rendering and animation is working. If you would like to see a feature implemented, don't hesitate to add it to the issues list, or better is to create pull request 😎

Main metrics

Overview
Name With Ownercanvg/canvg
Primary LanguageTypeScript
Program languageJavaScript (Language Count: 6)
Platform
License:MIT License
所有者活动
Created At2014-12-07 19:18:53
Pushed At2025-10-18 19:23:03
Last Commit At2025-10-18 23:21:04
Release Count22
Last Release Namev3.0.11 (Posted on )
First Release Namev1.4 (Posted on )
用户参与
Stargazers Count3.8k
Watchers Count64
Fork Count619
Commits Count1.1k
Has Issues Enabled
Issues Count723
Issue Open Count112
Pull Requests Count551
Pull Requests Open Count14
Pull Requests Close Count479
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private