download an svg element as an SVG or PNG file, including CSS defined styles
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Using np May 8, 2017
src Style fixes May 8, 2017
.gitignore New features and improved demo Apr 25, 2017
.npmignore Adding browser files to npm publish Oct 3, 2015
.travis.yml Only need to test latest node Apr 26, 2017
.zuul.yml Fix bug introduced in v8 and tests Apr 26, 2017 New features and improved demo Apr 25, 2017 v0.9.0 May 8, 2017 Added travis badge Oct 29, 2015
bower.json Use computed-styles Oct 27, 2015
browser.js Using np May 8, 2017
browser.min.js Fix duplicated xmlns in IE 11 #7 May 8, 2017
esdoc.json asSvg and asPng now return SvgSaver instance Sep 30, 2015
package.json v0.9.0 May 8, 2017 Use FileSaver as a dep May 8, 2017
yarn.lock Using np May 8, 2017


Download an SVG element as an SVG or PNG file, including CSS defined styles.

NPM version Downloads Downloads

Build Status Codacy Badge

js-semistandard-style License


  • Download <svg> by element object.
  • Download as SVG or PNG file.
  • Copies SVG element styles as rendered in the browser, including styles defined in CSS style sheets.
  • Copies only SVG relevant and non-default styles. See here.
  • Computed styles are in-lined for maximum compatibility.



npm install svgsaver


bower install svgsaver


jspm install svgsaver=npm:svgsaver


For maximum compatibility across browsers include eligrey/FileSaver.js/ and eligrey/canvas-toBlob.js. See Compatibility-Chart for more information.


var SvgSaver = require('svgsaver');                 // if using CommonJS environment
var svgsaver = new SvgSaver();                      // creates a new instance
var svg = document.querySelector('#mysvg');         // find the SVG element
svgsaver.asSvg(svg);                                // save as SVG



Based on previous work on Hypercubed/angular-downloadsvg-directive. Some portions of this code inspired by raw and moagrius/copycss.


MIT License