#svg #dom


Library to represent an SVG as a DOM

29 releases (17 breaking)

✓ Uses Rust 2018 edition

0.17.0 Jun 12, 2019
0.16.1 Mar 15, 2019
0.16.0 Jan 2, 2019
0.15.0 Dec 13, 2018
0.2.0 Nov 4, 2016

#21 in Parser implementations

Download history 644/week @ 2019-04-05 430/week @ 2019-04-12 418/week @ 2019-04-19 435/week @ 2019-04-26 340/week @ 2019-05-03 354/week @ 2019-05-10 317/week @ 2019-05-17 318/week @ 2019-05-24 345/week @ 2019-05-31 410/week @ 2019-06-07 426/week @ 2019-06-14 505/week @ 2019-06-21 309/week @ 2019-06-28 557/week @ 2019-07-05 374/week @ 2019-07-12

2,115 downloads per month
Used in 4 crates (1 directly)


3.5K SLoC


Build Status Crates.io Documentation

svgdom is an SVG Full 1.1 processing library, which allows you to parse, manipulate, generate and write an SVG content.

Note: the library itself is pretty stable, but API is constantly changing.


svgdom is designed to simplify generic SVG processing and manipulations. Unfortunately, an SVG is very complex format (PDF spec is 826 pages long), with lots of features and implementing all of them will lead to an enormous library.

That's why svgdom supports only a static subset of an SVG. No scripts, external resources and complex CSS styling. Parser will convert as much as possible data to a simple doc->elements->attributes structure.

For example, the fill parameter of an element can be set: as an element's attribute, as part of a style attribute, inside a style element as CSS2, inside an ENTITY, using a JS code and probably with lots of other methods.

Not to mention, that the fill attribute supports 4 different types of data.

With svgdom you can just use node.has_attribute(AttributeId::Fill) and don't worry where this attribute was defined in the original file.

Same goes for transforms, paths and other SVG types.

The main downside of this approach is that you can't save an original formatting and some data.

See the preprocessor doc for details.


  • The element link(IRI, FuncIRI) is not just a text, but an actual link to another node.
  • At any time you can check which elements linked to the specific element. See Node's doc for details.
  • Support for many SVG specific data types like paths, transforms, IRI's, styles, etc. Thanks to svgtypes.
  • A complete support of text nodes: XML escaping, xml:space.
  • Fine-grained control over the SVG output.


  • Only SVG elements and attributes will be parsed.
  • Attribute values, CDATA with CSS, DOCTYPE, text data and whitespaces will not be preserved.
  • UTF-8 only.
  • Only most popular attributes are parsed, other stored as strings.
  • No compressed SVG (.svgz). You should decompress it by yourself.
  • CSS support is minimal.
  • SVG 1.1 Full only (no 2.0 Draft, Basic, Tiny subsets).

Differences between svgdom and SVG spec

  • Library follows SVG spec in the data parsing, writing, but not in the tree structure.
  • Everything is a Node. There are no separated ElementNode, TextNode, etc. You still have all the data, but not in the specific struct's. You can check the node type via Node::node_type().


Rust >= 1.32


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~11K SLoC