skillfed

CairoSVG

A Simple SVG Converter based on Cairo

cairosvg v2.9.0 20.7M downloads/30d#1,029 on PyPI948
Copyleft license LGPL-3.0-or-later Active released

What it is and what it does

CairoSVG is a Python library that renders SVG files to multiple output formats—PDF, EPS, PostScript, and PNG—by delegating rendering to the Cairo graphics engine. It wraps Cairo functionality through cairocffi and uses cssselect2 and tinycss2 to parse SVG stylesheets and selectors, defusedxml to safely parse XML, and Pillow for raster image handling. The library is stable (Production/Stable status), actively maintained, and supports modern Python versions from 3.10 onward.

Typical use cases include batch conversion of vector graphics for print or web distribution, programmatic SVG-to-PDF generation in document pipelines, and rendering SVG content to raster formats when vector output is not required. The copyleft LGPL license means you must disclose modifications if you redistribute the library, but using it as a dependency in your own application is straightforward.

Use it for:

  • Convert SVG graphics to PDF for embedding in reports or print-ready documents.
  • Batch export SVG icons or illustrations to PNG for web use or mobile apps.
  • Generate PostScript or EPS output from SVG for legacy printing systems or archival.
  • Programmatically render SVG content in a document generation pipeline without manual design tool steps.
  • Transform vector graphics to raster formats when downstream tools require PNG or similar formats.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

CairoSVG converts SVG files to PDF, EPS, PS, and PNG formats using the Cairo graphics library.

Yes. CairoSVG is production-stable, actively maintained, has low install friction, no known vulnerabilities, and solves a concrete problem (SVG conversion to multiple formats). The LGPL copyleft license is standard for graphics libraries and poses no barrier for most use cases. Install if you need reliable SVG-to-PDF/PNG/EPS conversion.

Install

cairosvg on PyPI

pip

pip install cairosvg

uv

uv add cairosvg

poetry

poetry add cairosvg

Installing CairoSVG

Before you install

Low install friction with a pure Python wheel distribution. Active maintenance with a recent release (154 days ago) and ongoing repository activity; supports current Python versions (3.10–3.14).

License in practice

LGPL-3.0-or-later copyleft license requires that derivative works and modifications remain under the same license; acceptable for most projects but review your distribution model if you plan to bundle or modify the source.

Quickstart

pip install cairosvg

import cairosvg

carosvg.svg2pdf(url='input.svg', write_to='output.pdf')

Requires Python 3.10 or later; Cairo graphics library must be available on the system (typically pre-installed on most Linux distributions, may require separate installation on macOS or Windows).

Verify before relying

  • Whether Cairo system library is pre-installed or requires manual setup on Windows and macOS platforms.
  • Performance characteristics when converting large or complex SVG files in batch operations.

Package facts

License LGPL-3.0-or-later (copyleft)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 5 — cairocffi, cssselect2, defusedxml, pillow, tinycss2
Maintenance actively maintained — 154 days since the last release
Last repo commit
First released
Downloads 20,670,714/month — #1,029 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: cairosvg-2.9.0-py3-none-any.whl

Keywords: svg, converter, cairo, pdf, png, postscript

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: End Users/DesktopOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Multimedia :: Graphics :: Graphics Conversion

Tags

svg to pdf convertersvg to png exportcairo svg conversionbatch svg conversionsvg graphics renderingsvg postscript exportvector to raster conversion
svg-conversiondocument-generationgraphics-rendering

More Graphics Conversion packages