svglib
A pure-Python library for reading and converting SVG
What it is and what it does
Svglib is a pure-Python library that reads SVG files (plain or compressed) and converts them into ReportLab Drawing objects. These objects can then be rendered to PDF, EPS, SVG, or bitmap formats. The library handles SVG gradients, conditional rendering, and clip paths, though it has known limitations around CSS imports, mask elements, and ForeignObject support.
You can use it as a Python package to programmatically convert SVG to other formats, or as a command-line tool (svg2pdf) to batch-convert SVG files to PDF from the shell. It supports Python 3.9+ and PyPy3, with dependencies on reportlab, lxml, pillow, cssselect2, and tinycss2.
Use it for:
- Convert SVG graphics to PDF for document generation or archival
- Embed SVG images in ReportLab-based PDF reports or Platypus documents
- Batch-convert SVG files to PDF from the command line using the svg2pdf tool
- Render SVG to bitmap formats via ReportLab's renderPM backend
- Build tools that need to programmatically transform vector graphics to print-ready formats
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Svglib reads SVG files and converts them to ReportLab Drawing objects, which can then be rendered to PDF, bitmap, or other formats supported by ReportLab.
Yes. Svglib is actively maintained, has no known vulnerabilities, low install friction, and solves SVG-to-PDF/bitmap conversion well for most common use cases. The LGPL-3.0-or-later license is copyleft, so disclose modifications if you distribute derivatives. Known limitations (no @import, no mask elements, limited CSS) are documented; verify they don't block your specific SVG files.
Install
svglib on PyPI
pip
pip install svglibuv
uv add svglibpoetry
poetry add svglibInstalling svglib
Before you install
Low install friction: pure Python wheel with five runtime dependencies. Actively maintained as of 2026-08-14 with no known security vulnerabilities.
License in practice
Licensed under LGPL-3.0-or-later (copyleft). You must disclose source code modifications and make the library available under the same license if you distribute derivative works.
Quickstart
pip install svglib
from svglib.svglib import svg2rlg
from reportlab.graphics import renderPDF
drawing = svg2rlg("file.svg")
renderPDF.drawToFile(drawing, "file.pdf")
Requires Python 3.9 or later. Bitmap output requires an additional renderPM backend; PDF output does not.
Verify before relying
- Whether CSS attribute support covers the specific stylesheets in your SVG files
- Performance characteristics for large or complex SVG files
- Behavior when SVG files use unsupported features (@import rules, mask elements, ForeignObject)
Package facts
| License | LGPL-3.0-or-later (copyleft) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — cssselect2, lxml, pillow, reportlab, tinycss2 |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,940,849/month — #2,006 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: svglib-2.2.0-py3-none-any.whl
Keywords: PDF, SVG, conversion, graphics, reportlab
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
CairoSVGCairoSVG converts SVG files to PDF, EPS, PS,…
copyleft · top 5,000 on PyPI
svgutilssvgutils lets you programmatically edit, scale,…
permissive · top 15,000 on PyPI
aggdrawaggdraw provides high-quality 2D drawing for…
permissive · top 15,000 on PyPI
svgwriteCreates SVG drawings programmatically by…
permissive · top 5,000 on PyPI
svg.pyGenerates SVG files programmatically in Python…
permissive · top 15,000 on PyPI
svgelementssvgelements parses SVG files and provides…
permissive · top 5,000 on PyPI
rlPyCairoA Cairo-based rendering backend plugin that…
permissive · top 5,000 on PyPI
drawsvgProgrammatically generate SVG images and…
permissive · top 5,000 on PyPI
sphinxcontrib-svg2pdfconverterConverts SVG images to PDF or PNG for Sphinx…
permissive · top 15,000 on PyPI
potracerConverts bitmap images to vector graphics by…
copyleft · top 15,000 on PyPI