CairoSVG
A Simple SVG Converter based on Cairo
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 cairosvguv
uv add cairosvgpoetry
poetry add cairosvgInstalling 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
Tags
More Graphics Conversion packages
Pillow adds image processing capabilities to…
permissive · top 100 on PyPI
fonttoolsfonttools manipulates font files in multiple…
permissive · top 1,000 on PyPI
weasyprintWeasyPrint converts HTML and CSS into PDF…
permissive · top 1,000 on PyPI
pillow-heifpillow-heif adds HEIF/HEIC image format support…
copyleft · top 5,000 on PyPI
rasterioRasterio reads and writes geospatial raster…
permissive · top 5,000 on PyPI
pi-heifDecodes HEIF/HEIC image files and integrates…
copyleft · top 5,000 on PyPI
sphinxcontrib-svg2pdfconverterConverts SVG images to PDF or PNG for Sphinx…
permissive · top 15,000 on PyPI
svglibSvglib reads SVG files and converts them to…
copyleft · top 5,000 on PyPI
typstCompiles Typst markup documents to PDF, PNG,…
unclear · top 15,000 on PyPI
vtracerConverts raster images (JPG, PNG) into vector…
permissive · top 15,000 on PyPI
rlPyCairoA Cairo-based rendering backend plugin that…
permissive · top 5,000 on PyPI
svgutilssvgutils lets you programmatically edit, scale,…
permissive · top 15,000 on PyPI
resvg_pyConverts SVG documents to raster image bytes…
unclear · top 5,000 on PyPI
scourScour optimizes and cleans SVG files by…
permissive · top 15,000 on PyPI
napari-svgNapari-svg is a plugin that exports image data…
permissive · top 15,000 on PyPI
svg.pyGenerates SVG files programmatically in Python…
permissive · top 15,000 on PyPI