Convert SVG to PNG on the Command Line
Automate SVG-to-PNG conversion in build scripts, CI pipelines, and batch workflows using these CLI tools.
Drop your image here
Supports PNG, JPG, BMP, WEBP up to 5MB
Inkscape CLI (Best Quality)
Inkscape provides the best SVG rendering for PNG export.
- Single file: inkscape --export-filename=output.png --export-dpi=96 input.svg
- 300 DPI print: inkscape --export-filename=logo-print.png --export-dpi=300 logo.svg
- Exact pixel size: inkscape --export-filename=icon.png --export-width=512 icon.svg
- Batch script (bash): for f in *.svg; do inkscape --export-filename=${f%.svg}.png $f; done
- Inkscape 1.0+: inkscape --actions='export-dpi:300;export-do' input.svg
Sharp (Node.js — Fast and Scriptable)
Sharp is the fastest Node.js image conversion library.
- Install: npm install sharp
- Basic: const sharp = require('sharp'); sharp('icon.svg').png().toFile('icon.png')
- With resize: sharp('logo.svg').resize(512, 512).png().toFile('logo-512.png')
- Batch: use fs.readdirSync to iterate SVG files and sharp in a loop
- SVG with custom size: sharp(Buffer.from(svgString), { density: 300 }).png()
ImageMagick (Widely Available)
ImageMagick is pre-installed on most Linux servers and macOS via Homebrew.
- Install: brew install imagemagick (macOS) or apt-get install imagemagick (Ubuntu)
- Convert: convert -density 300 logo.svg logo.png
- Resize: convert -density 300 -resize 512x512 logo.svg icon.png
- Batch: mogrify -format png -density 300 *.svg
- Note: ImageMagick uses Ghostscript for SVG rendering — quality may differ from browser rendering
Frequently Asked Questions
Which CLI tool gives the most browser-accurate SVG to PNG conversion?
Inkscape uses the same Resvg library as modern browsers and gives the closest match to what users see. Sharp (using libvips/librsvg) is close and faster. ImageMagick (using Ghostscript) can have minor rendering differences.
How do I batch convert a folder of SVG files to PNG?
Bash with Inkscape: for f in *.svg; do inkscape --export-filename=${f%.svg}.png $f; done. Node.js with Sharp: fs.readdirSync('.').filter(f=>f.endsWith('.svg')).forEach(f=>sharp(f).png().toFile(f.replace('.svg','.png'))).
How do I set the output resolution with Sharp?
sharp(input, { density: 300 }).png() — density sets the rendering DPI. Higher density = larger pixel output from the same SVG viewBox size.
Can I convert SVG with custom fonts to PNG?
Inkscape: yes if the fonts are installed on the system. Sharp/libvips: only if the fonts are available to the librsvg renderer. For font-safe conversion, use Puppeteer to render in a headless browser.
How do I use Puppeteer to convert SVG to PNG?
const page = await browser.newPage(); await page.setContent(svgHtml); const screenshot = await page.screenshot({type:'png'}); — Puppeteer uses Chrome's full SVG renderer, handling all SVG features including filters and fonts.
Related guides
Ready to Convert Your Image to SVG?
Free online converter — no sign-up, no watermarks, results in under 3 seconds.
Try It Free — Convert Image to SVG