SVG libraries
SVG libraries do one or more of 3 jobs: render SVG to pixels (rasterize to PNG or draw on a canvas), parse SVG into a tree you can inspect or change, and generate SVG from code. Rendering is the hard part: full SVG needs CSS, text layout and filters, so renderers differ a lot in coverage. resvg and librsvg have the most complete static rendering outside browsers; nothing outside a browser runs SVG scripts.
In the table, Read means the library can load (and usually render) SVG files; Write means it can create or save SVG.
| Language | Library | Read | Write | Notes |
|---|---|---|---|---|
| C/C++ | librsvg | yes | no | GNOME renderer to Cairo (PNG, PDF), very complete, LGPL |
| C/C++ | LunaSVG | yes | no | small C++ renderer, DOM access, MIT |
| C/C++ | NanoSVG | yes | no | single header parser to Bézier paths, basic rasterizer |
| C# | SVG.NET | yes | yes | object model, read / modify / write, renders with System.Drawing |
| C# | Svg.Skia | yes | no | renders with SkiaSharp to PNG, JPEG, PDF, cross-platform |
| Java | Apache Batik | yes | yes | full toolkit: DOM, renderer, PNG/JPEG/PDF transcoders, SVGGraphics2D |
| Java | JSVG | yes | no | small, fast renderer to Graphics2D, used by IntelliJ |
| Java | JFreeSVG | no | yes | Graphics2D that writes SVG, GPL-3.0 |
| Go | canvas | yes | yes | vector drawing library: SVG in, SVG/PDF/PNG out |
| Go | oksvg | yes | no | rasterizes SVG icons with rasterx |
| Go | SVGo | no | yes | generate SVG with function calls, CC BY 4.0 |
| Python | CairoSVG | yes | no | SVG to PNG, PDF, PS with Cairo, LGPL |
| Python | svglib | yes | no | SVG to ReportLab drawings and PDF, no Cairo needed, LGPL |
| Python | drawsvg | no | yes | generate SVG and SVG animations, Jupyter display |
| Ruby | ruby-vips | yes | no | renders SVG with libvips + librsvg, fast thumbnails |
| Ruby | Victor | no | yes | build SVG with a Ruby DSL, no dependencies |
| Rust | resvg | yes | yes | the most complete static renderer, pure Rust; usvg parses and normalizes |
| Rust | svg | yes | yes | compose and parse SVG documents (no rendering) |
| PHP | php-svg | yes | yes | pure PHP: create, parse, edit, rasterize with GD |
| PHP | Imagick | yes | no | ImageMagick extension: SVG to PNG, JPEG, PDF |
By language#
- SVG libraries for C/C++ Open-source C and C++ libraries to render and parse SVG: librsvg, LunaSVG and NanoSVG. Comparison and code examples for converting SVG to PNG.
- SVG libraries for C# Open-source .NET libraries to read, write and render SVG in C#: SVG.NET and Svg.Skia. Comparison and code examples for converting SVG to PNG.
- SVG libraries for Java Open-source Java libraries to render, parse and generate SVG: Apache Batik, JSVG and JFreeSVG. Comparison and code examples for SVG to PNG.
- SVG libraries for Go Open-source Go libraries to render, convert and generate SVG: tdewolff/canvas, oksvg and SVGo. Comparison and code examples for SVG to PNG and generating SVG.
- SVG libraries for Python Open-source Python libraries to convert and generate SVG: CairoSVG, svglib and drawsvg. Comparison and code examples for SVG to PNG and PDF.
- SVG libraries for Ruby Open-source Ruby libraries to render and generate SVG: ruby-vips for converting SVG to PNG and thumbnails, and Victor for building SVG with Ruby code.
- SVG libraries for Rust Open-source Rust crates to render, parse and generate SVG: resvg (with usvg) and the svg crate. Comparison and code examples for SVG to PNG and writing SVG.
- SVG libraries for PHP Open-source PHP libraries to create, parse and convert SVG: php-svg (pure PHP) and the Imagick extension. Comparison and code examples for SVG to PNG.