Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A SVG to PNG converter, using PhantomJS.
Branch: master
Latest commit 0e048c 1 @XhmikosR XhmikosR committed Clean up JSHint options
Failed to load latest commit information.
lib Clean up JSHint options
test Clean up JSHint options
.gitignore Version 1.0.0
.jshintrc Clean up JSHint options
.travis.yml Test on io.js, but not 0.8
LICENSE.txt Clean up metadata Add pointer @skyzyx's CLI.
package.json Version 1.1.1

SVG-to-PNG Converter Using PhantomJS

You have a SVG file. For whatever reason, you need a PNG. svg2png can help.

svg2png("source.svg", "dest.png", function (err) {
    // PNGs for everyone!

Maybe you need to scale the image while converting? We can do that too:

svg2png("source.svg", "dest.png", 1.2, function (err) {
    // 1.2×-sized PNGs for everyone!

The scale factor is relative to the SVG's viewbox or width/height attributes, for the record.

svg2png is built on the latest in PhantomJS technology to render your SVGs using a headless WebKit instance. I have found this to produce much more accurate renderings than other solutions like GraphicsMagick or Inkscape. Plus, it's easy to install cross-platform due to the excellent phantomjs npm package—you don't even need to have PhantomJS in your PATH.


@skyzyx made a CLI version of this; you should go check it out if you're into using the command line.

Something went wrong with that request. Please try again.