SVG is the format you want to keep as long as possible. It's resolution-independent, it compresses well, and it's just XML — easy to inspect and easy to tweak by hand. But there's a long list of places that won't accept it: email clients, some CMS platforms, ad networks, print workflows, anything that rejects uploads for security reasons. That's when you need to rasterize. This guide walks through the mechanics — how to pick dimensions, how to handle transparency, and the edge cases that silently break exports even when the source file looks fine.
1. The fundamental difference between vector and raster
A raster image is a grid of pixels. PNG, JPEG, WebP, AVIF — all raster. Each file stores a fixed number of colour samples arranged in rows, and scaling the image up means the decoder has to invent pixels that weren't there before (usually via bilinear or bicubic interpolation, which looks soft and blurry on edges).
A vector image is a list of drawing instructions. SVG stores things like "draw a circle of radius 20 centred at (50, 50), filled red" or "stroke a bezier curve from this point to that point". When you render an SVG at any size, the renderer re-executes those instructions at the target resolution, so edges stay crisp at 16×16 or at 4000×4000. There's no "native resolution" — only whatever you decide to draw at today.
Converting SVG to PNG is therefore a one-way operation. You're taking a mathematical description and freezing it into pixels at one specific size. The moment you do, you've lost the ability to scale cleanly without re-rasterizing from the original. Keep your SVG sources in version control, even after you've exported PNGs from them.
2. Why you'd ever need to convert SVG → PNG
If SVG is so much better, why rasterize at all? In 2026, a few real reasons remain:
- Email attachments and newsletters. Most email clients still don't render inline SVG reliably — Outlook in particular has a long history of stripping or mangling SVG content. Marketing teams default to PNG or JPEG for embedded images because they render identically everywhere.
- Platforms that reject SVG for security reasons. SVG is XML and can contain
<script>tags,onloadhandlers, external references, and other active content. CMS platforms, forums, and user-generated content sites routinely block SVG uploads to avoid XSS vectors. Rasterizing to PNG sidesteps the problem entirely. - Legacy print workflows. Plenty of printers and print shops want TIFF or PNG at 300 DPI. Their prepress software may support SVG in theory but produce inconsistent results across versions, and the safer default is to send them a high-resolution raster they've seen a thousand times before.
- Social media uploads. Instagram, most messaging apps, and many social platforms don't accept SVG at all — you have to upload PNG, JPEG, or WebP. Same for thumbnails, OG images, and anywhere a crawler is going to fetch an image to display in a card.
3. Choosing the right output resolution
This is the part people get wrong most often. The SVG has no inherent pixel size — you have to pick one. Here's how to think about it.
For the web, ignore DPI. Browsers render images based on CSS pixels, not physical inches. If an icon displays at 48×48 CSS pixels and you want it to look sharp on retina screens, you need a 96×96 pixel PNG (2×) — and for the occasional 3× display, a 144×144 version. You don't need to set a DPI anywhere; the pixel dimensions are what matter.
For print, DPI is the unit. The math is: pixels = inches × DPI. A 4-inch-wide logo printed at 300 DPI needs to be 1,200 pixels wide. A business card photo printed at 600 DPI needs 2,400 pixels per inch of width. When a print shop says "send us 300 DPI", they're really saying "send us enough pixels that, at the physical output size, you hit 300 per inch".
Common preset sizes worth knowing:
| Use case | Pixel size | Notes |
|---|---|---|
| Favicon | 32×32, 180×180 | iOS touch icon is 180×180 |
| App icon (Android) | 512×512 | Play Store listing |
| OG / social card | 1200×630 | Facebook, Twitter, LinkedIn |
| Email logo | 600 wide @ 2× | Most emails max out at 600 CSS px |
| Print at 300 DPI | inches × 300 | Business cards, flyers, posters |
When in doubt, export larger than you think you need. Downscaling a 2000-pixel PNG to 400 produces a clean result; upscaling a 200-pixel PNG to 400 does not.
4. Controlling background transparency
SVG's default background is transparent — there's no "paper" underneath the shapes. When you rasterize, PNG supports an alpha channel, so that transparency carries through naturally. But a few things can accidentally add a solid background.
viewBox vs width/height. The viewBox attribute defines the coordinate system your drawing uses (for example, 0 0 100 100). The width and height attributes define how big the SVG wants to be rendered. If you want the PNG output to match a specific pixel size without distortion, set both explicitly — width="512" height="512" on a viewBox="0 0 100 100" will render at 512×512 pixels while keeping the internal coordinate system clean.
Transparent by default, solid by accident. If your SVG includes a <rect> covering the whole canvas with a white fill, that rectangle will show up as an opaque white background in the PNG. Remove it if you want true transparency. Conversely, if you want a white background in the exported PNG (for example, for a printer that doesn't handle transparency), either add a white rect yourself or ensure your rasterizer has a "flatten to white" option enabled.
CSS background is ignored. Applying background: white in a stylesheet or inline style on the SVG root does not draw a white rectangle — CSS background in SVG is not painted by most rasterizers. Use a <rect fill="white"> as the first child of your SVG instead.
Need to rasterize right now?
OnlyFormat's SVG to PNG converter runs entirely in your browser — set a custom size, keep or flatten transparency, and export without uploading your file anywhere.
5. Rasterization edge cases
Most SVGs rasterize cleanly. A handful of features trip up specific renderers, and these are the ones worth knowing before you're debugging a mysteriously broken export at 2 a.m.
foreignObject. SVG supports embedding HTML inside a <foreignObject> element, which is handy for things like HTML-formatted labels. Browsers render it correctly, but command-line rasterizers often ignore it entirely — you'll get the SVG background with nothing where the HTML was supposed to be. If you need reliable export, bake any foreignObject content into SVG text or shapes before rasterizing.
Embedded raster images. An SVG can include <image href="photo.jpg"/> to embed a bitmap. When you rasterize at a size larger than that bitmap's native resolution, the embedded image will look pixelated — rasterizing at higher DPI only helps the vector parts. Either embed raster images at their intended output size, or use image-rendering: auto (the default) and accept the softness.
External CSS styling. If your SVG relies on styles defined in a separate stylesheet (<link rel="stylesheet"> or inherited page CSS), a standalone rasterizer won't have access to them. Inline all styles into the SVG — either as a <style> block inside the file or as attribute-level styles on each element — before export.
Animation frames. SMIL animations, CSS keyframes, and JavaScript-driven motion all collapse to a single frame when rasterized. Most tools capture the state at time zero. If you need a specific animation frame, seek the SVG in a browser first and export after the animation has run, or render each frame individually and assemble them into an animated format afterwards.
Unsupported filters. SVG filter primitives like feGaussianBlur, feDropShadow, and feTurbulence are well-supported in modern browsers, but lightweight rasterizers may skip them silently. If a drop shadow disappears or a blur looks crisp in your exported PNG, the filter probably wasn't rendered. Test with your actual rasterizer before shipping — don't assume because it looked right in Chrome, it will look right when exported.
6. Batch rasterization workflow for icon systems
If you maintain an icon library with 50+ SVGs and need PNG fallbacks at multiple sizes, do this once instead of by hand. A reasonable workflow:
- Standardize the source. Every SVG in your icon set should use the same viewBox (for example,
0 0 24 24), have no intrinsicwidth/heightattributes, and inline all styles. This makes every icon behave identically at export time. - Define a size matrix. Decide which output sizes you need — typical: 24, 48, 96, 192, 512. The smaller sizes are for direct display; 192 and 512 cover PWA and app-store requirements.
- Use a scriptable rasterizer. resvg (a Rust-based SVG renderer) or Inkscape's command-line mode (
inkscape --export-type=png --export-width=512) are the usual choices. Inkscape matches browser rendering most closely; resvg is faster and produces clean results for well-formed SVGs. - Loop the matrix. For each icon and each size, export to a file named like
icons/home/home-48.png. A ten-line shell script or Node script covers this. - Optimize the output. Run the resulting PNGs through pngquant or similar to palette-compress where possible. An icon-sized PNG usually drops to 2–4 KB after optimization.
- Keep the SVGs in source control. The PNGs are build artifacts — regenerable from the SVGs at any time. Treat them that way.
Set this pipeline up once and you'll never manually "export as PNG" from a graphics tool again. Every new icon added to the set automatically ships at every required size.
Frequently asked questions
Q. Will I lose quality converting SVG to PNG?
A. The SVG itself doesn't lose anything — it's still a perfect vector description — but the PNG you produce is frozen at one pixel size. At the size you export, quality is effectively lossless (PNG stores exact pixels), but the moment you scale that PNG up in a browser or editor, you'll see the soft, blurry edges that tell you it's raster. The fix isn't better export settings; it's either exporting at a larger size up front or shipping the SVG directly wherever it's supported.
Q. What DPI or size should I pick?
A. For web use, think in pixel dimensions, not DPI — browsers don't care about DPI metadata. Start from the CSS size you plan to display (say 200×200 px) and export at 2× for retina screens (400×400 px). For print, 300 DPI is the safe default: a 4-inch-wide logo needs a 1200-pixel-wide PNG. When in doubt, export larger — downscaling a too-big PNG looks fine, upscaling a too-small one never does.
Q. Why is my rasterized PNG smaller than expected?
A. Almost always a viewBox vs width/height mismatch. If your SVG declares width="100" height="100" but the viewBox is 0 0 24 24, some renderers honour the intrinsic size (100×100) and others scale the viewBox — and if neither is set, you get whatever default the renderer picks (often 300×150). Set explicit pixel dimensions on the root <svg> element when you export, or pass the target size to your rasterizer directly.
Q. Does SVG animation survive conversion?
A. No. PNG is a static format, so any SMIL animation, CSS keyframes, or JavaScript-driven motion is collapsed to a single frame at rasterization time. Most tools capture whatever state the animation is in at time t=0. If you need animated output, export each frame separately and assemble a WebP or APNG, or render the SVG to a short MP4 and use that instead.
Q. Can I convert PNG back to SVG?
A. Not meaningfully. PNG is pixels; SVG is shapes. Tools that claim PNG-to-SVG conversion are doing one of two things — either embedding the raster image inside an <image> element (which gains you nothing) or vector-tracing it (which works for simple, high-contrast logos but mangles anything photographic). The rule of thumb: keep the SVG source if you ever plan to re-export at new sizes.
References
- W3C Recommendation — Scalable Vector Graphics (SVG) 2
- MDN Web Docs — SVG reference and SVG viewBox attribute
- Inkscape — Command Line Export Documentation
- resvg — Rust SVG rendering library,
github.com/RazrFalcon/resvg - W3C — Portable Network Graphics (PNG) Specification (3rd edition)
About the OnlyFormat Editorial Team
OnlyFormat's editorial team is made up of working web developers and image-workflow engineers who ship file-conversion tooling for a living. Every guide is reviewed against primary sources — W3C/WHATWG specifications, IETF RFCs, MDN Web Docs, ISO/IEC media standards, and the official documentation of libraries we actually use in production (libwebp, libjpeg-turbo, libavif, FFmpeg, pdf-lib). We update articles when standards change so the guidance stays current.
Sources we cite: W3C · WHATWG · MDN Web Docs · IETF RFCs · ISO/IEC · libwebp · libavif · FFmpeg · pdf-lib