svglab

The Python library for parsing, manipulating, and optimizing SVG files. Everything you need to work with SVG in Python, all in one place.

code

Parse & Serialize

Easily parse SVG files into a structured object model and serialize them back to SVG format.

transform

Manipulate

Create, edit, and delete elements and attributes programmatically.

speed

Optimize & Minify

Optimize SVG files by removing extraneous whitespace, lowering precision of floating-point numbers, and other techniques to reduce file size while preserving visual fidelity.

verified_user

Robust Typing & Runtime Validation

svglab leverages Python's type hints to provide a rich development experience with static type checking. Runtime type validation with Pydantic ensures your data is always valid.

format_paint

Configurable Formatting

Customize the output format of your SVG files with configurable indentation, attribute ordering, floating-point precision and 20+ other options.