SVG and PNG differ in what the file actually holds. Open an SVG and you find XML text that describes shapes and paths, which is why it renders at any size without losing quality. A PNG is a fixed grid of pixels, compressed without data loss.
SVG is the usual pick for logos and icons, with diagrams close behind. PNG fits screenshots, and detailed raster art that needs transparency.
The HTTP Archive 2024 Web Almanac puts PNG at 28.4% of images on mobile pages and SVG at 6.4%. Over two years, though, SVG usage grew 36% in relative terms while PNG grew 1%. SVG is still the smaller slice, but it’s the one moving.
How Do SVG and PNG Store an Image?
Every other difference between these two formats traces back to what sits inside the file.
| Attribute | SVG | PNG |
|---|---|---|
| Stored as | Drawing instructions in XML text | Pixel samples in a compressed grid |
| Specification | SVG 1.1 Second Edition (W3C Recommendation, 16 August 2011) | PNG Third Edition (W3C Recommendation, 24 June 2025) |
| MIME type | image/svg+xml | image/png (image/apng for animation) |
| File extension | .svg, or .svgz when compressed on disk | .png |
Open an SVG graphic in a text editor and you read markup. There’s a <circle> with a center and radius, a <path> with drawing commands, and fills. MDN Web Docs notes that this text form lets the file be searched, indexed, scripted and compressed.
Because the format builds on XML markup, a script can rewrite any value in the file. A PNG has no such layer. It holds an eight-byte signature, an IHDR header chunk, compressed IDAT image data and an IEND trailer, and every chunk carries its own CRC check.
Some popular comparison guides get this wrong, but PNG is a raster format, not a vector one. The W3C describes it as a format for the lossless storage of static and animated raster images.
As of October 2026, SVG 1.1 Second Edition is still the stable Recommendation. SVG 2 became a W3C Candidate Recommendation Snapshot on 6 October 2026 and is expected to advance no earlier than 1 December 2026.
Which Format Stays Sharp on Retina and High-DPI Screens?
Only SVG stays sharp across screen densities. A PNG looks right at the density it was exported for and soft above it.
The HTTP Archive 2024 Web Almanac renders its mobile crawl at a device pixel ratio of 3x, so each CSS pixel maps to 9 device pixels.
That is what the screen’s pixel density does to a raster asset. A 100 by 100 CSS pixel icon needs a 300 by 300 pixel PNG at 3x, nine times the pixels of the 1x file.
With PNG, the usual fix is serving 1x, 2x and 3x files through srcset with x descriptors, which let the browser pick a file by screen density (Web Almanac 2024). Every extra file is another export to upload and cache.
An SVG needs one file. The viewBox attribute, defined in the SVG 2 specification, maps the drawing’s coordinates onto whatever size the page gives it.
SVG isn’t perfect here, though. At 16 or 20 pixels, a thin stroke can straddle two pixel rows and render soft. The shape-rendering property lets an author hint that crisp edges matter more than smoothing, at the price of jagged diagonals.
Tiny interface icons are the exception to the whole argument. A pixel-fitted PNG can still beat a scaled SVG at that size.
How SVG and PNG File Sizes Compare by Image Type
For flat, geometric artwork, SVG is usually the lighter file. Once the image is detailed raster content, PNG wins, since an SVG can only carry a bitmap by embedding it, and the embedded bitmap brings its own weight.
Fixed KB ranges per image type circulate in comparison guides, but they rarely say how the files were made or tested. Treat them as rough illustrations and measure your own assets.
Published tests give a few numbers worth keeping in mind. The median PNG on mobile pages comes in at 3.8 bits per pixel (HTTP Archive Web Almanac, 2024), while the lossless rule of thumb for 8-bit RGB is about 12 bits per pixel, a 2:1 ratio (HTTP Archive Web Almanac, 2024).
On the SVG side, LogRocket’s tests took the FlagKit icon set from 793kB raw to 127kB with Brotli level 3, and to 55kB with SVGO added (LogRocket, 2021). An HD world map SVG from amCharts went from 1.3MB raw to 880kB after SVGO (LogRocket, 2021).
Put those first two PNG numbers next to each other and the median web PNG looks cheap, well under the 12 bits per pixel that lossless RGB roughly costs.
The Web Almanac’s 2021 edition points at common PNG tooling, which reduces color palettes and adds dithering before encoding. Flat graphics also compress better than photographs, so tooling explains only part of the gap.
How PNG Compression Works
An encoder filters each scanline with one of five filter types (None, Sub, Up, Average or Paeth), compresses the result with DEFLATE and splits the output into IDAT chunks. DEFLATE uses a sliding window of at most 32,768 bytes, according to the W3C PNG Third Edition.
OptiPNG recompresses files without losing any information, and version 7.9.1 is the stable release on its project page. TinyPNG goes the other way. It describes its engine as smart lossy compression, which trades exact pixel values for smaller files.
Skip lossy tools on assets that must match a brand color exactly.
How SVG Compression Works
An SVG gets smaller in the markup first, through minification, and then again in transit, through compression.
SVGO, the common minifier, strips editor metadata, comments, hidden elements and default values. LogRocket’s 2021 tests found it works best on exports from Sketch and Adobe Illustrator, since those carry comments and long names, along with over-precise numbers.
Cleaning up exports is the core of SVG optimization, but transfer compression does more of the work. In all three LogRocket test sets, Brotli on the unminified files saved more bytes than SVGO alone, and MDN lists HTTP compression and the .svgz format as the delivery options.
LogRocket concluded that minifying SVGs should not be a performance priority unless the files are large and needed above the fold. It also flags a maintenance cost, since minified files are harder to edit when fills and strokes change.
Effect on Page Speed and Core Web Vitals
Images are the Largest Contentful Paint element on 68% of mobile pages, according to the HTTP Archive 2024 Web Almanac.
Largest Contentful Paint is one of the three Core Web Vitals, per web.dev’s October 2024 update, so the heaviest image above the fold matters more than every icon on the page combined. Google Lighthouse weights load metrics such as first contentful paint and largest contentful paint, not total asset size (LogRocket, 2021).
My advice is to shrink the LCP image first. A hero PNG deserves attention long before a small SVG icon does.
Transparency and Color Support in SVG and PNG
Transparency in a PNG lives in an alpha channel, one value per pixel. An SVG has no background at all unless it draws one, and opacity is set shape by shape.
The names PNG-8, PNG-24 and PNG-32 come from image tools, not from the W3C specification, which defines five color types. Labels vary by tool, so check the color type instead of trusting the name.
| Tool label | Typically stored as | Transparency it can carry |
|---|---|---|
| PNG-8 | Indexed-color, up to 256 palette entries | Alpha per palette entry (tRNS chunk) |
| PNG-24 | Truecolor, 8 bits per sample | None, or one fully transparent color |
| PNG-32 | Truecolor with alpha, 8 bits per sample | 8-bit alpha, 256 opacity levels |
A truecolor PNG stores three RGB color samples per pixel plus an optional alpha sample, and sample depths run from 1 to 16 bits across color types. PNG does not premultiply color by alpha, so an editor can change transparency without touching the colors (W3C PNG Third Edition, 2025).
SVG handles the same jobs in markup. fill-opacity and stroke-opacity work on single shapes, opacity covers a whole group, mask gives soft-edged cutouts, and linearGradient and radialGradient take care of color blends.
Colors follow CSS color syntax, according to MDN, so hex, rgb() and named values all work. A gradient costs two stop colors and a direction instead of thousands of pixel values.
Photographic gradients, textures and scans still need per-pixel storage. MDN describes SVG as not generally useful for strictly bitmap or photographic images, though filters such as feGaussianBlur and feDropShadow cover simple shadows.
What Can You Edit, Style and Animate in SVG but Not in PNG?
Editors, CSS and JavaScript can all reach into an SVG, down to individual shapes, colors and text strings. A PNG gives them pixels and nothing else. It isn’t strictly static, mind you, since APNG is part of the W3C PNG specification and adds frame-based animation.
How the file is embedded decides how much of that control survives.
| Embedding method | Scripts run | Page CSS reaches the shapes |
|---|---|---|
<img> or CSS background | No | No |
Inline <svg> | Yes | Yes |
<object>, <iframe>, <embed> | Yes | No (separate document) |
MDN lists limits on SVG used as an image, namely that JavaScript is disabled and external resources cannot load. Those limits do not apply when the file is viewed directly or embedded as a document.
Inlining is the route when CSS or script control matters, and placing SVG in HTML directly also removes a network request.
Adobe Illustrator and Inkscape both edit SVG paths and text directly, and SVG is Inkscape’s native format. Figma exports a frame as either SVG or PNG, so one design yields both files. Adobe Photoshop edits PNG pixels, but layers stay in the PSD source because PNG has none.
MDN lists CSS, the DOM, JavaScript and SMIL as the standards SVG is built to work with. That leaves several ways to add motion, from animating SVG with CSS to SMIL or plain script.
Script-driven effects stop working inside an img tag, so keep them inline.
Accessibility follows the same split. SVG text can be searched and indexed, and the SVG 2 specification defines WAI-ARIA attributes for its elements, while a PNG relies on the alt attribute of whatever element displays it.
APNG covers simple PNG animation. MDN lists support from Chrome 59, Edge 12, Firefox 3, Opera 46 and Safari 8, and points to progress indicators as a good fit, but the frames stay raster and blur when scaled.
Which Format Should You Use for Logos, Icons, Screenshots and Photos?
SVG covers logos, icons and diagrams. PNG is for screenshots and detailed raster art, and ordinary photographs belong in neither.
| Asset | Pick | Reason |
|---|---|---|
| Logo | SVG | Flat shapes shown at many sizes |
| Icon set | SVG | MDN says to prefer the SVG version when one exists |
| Chart or diagram | SVG | Must stay accurate at any size |
| UI screenshot | PNG | Lossless encoding keeps text edges clean |
| Photograph | JPEG, WebP or AVIF | Lossy compression hides its loss in continuous tone |
Guides disagree about photographs. Several popular ones call PNG the only suitable photo format, while MDN steers photos toward lossy formats and keeps PNG for images that need transparency.
The split comes down to the alpha channel. JPEG has none, so a photo cut out against a transparent background needs PNG or lossless WebP, and every other photo can go lossy.
Lossless WebP images are typically 26% smaller than the same images in PNG, according to MDN.
MDN’s advice for raster images is WebP or AVIF first, with a <picture> fallback to PNG or JPEG for browsers that lack them. A full-width hero image is where that matters most, because it is a photograph and usually the heaviest file above the fold.
Icons that live outside the page follow the same drift. MDN notes that PNG files referenced by a link element have largely replaced ICO for a site’s favicon.
A quick way to decide is to look at where the file started. A drawing stays SVG, a screen capture stays PNG, and a camera frame gets exported as JPEG, WebP or AVIF.
SVG has a nice side benefit, since text inside the graphic can be localized by editing the file, per MDN, and no size variants need exporting. What it costs you is a sanitizing step for user uploads, plus channels, email in particular, that flatten it to a raster. PNG renders the same everywhere and keeps captures pixel-exact, but every size or language change means a re-export.
Where Each Format Breaks Down
SVG runs into trouble at the edges of the web, in email clients, with linked fonts and with spec features that aren’t finished. PNG mostly fails where a tool ignores its animation chunks.
Browsers rarely cause the trouble, since MDN lists both formats as supported in every version of Chrome, Edge, Firefox, Opera and Safari. Cross-browser compatibility testing stops at the browser, so the failures below sit outside it.
| Failure point | Format | What happens | Fix |
|---|---|---|---|
| Gmail | SVG | Rendered, but rasterized to PNG (Caniemail test, 16 September 2026) | Send a PNG in email |
| Linked web fonts | SVG | External stylesheets do not load in an image context | Outline the text or inline the SVG |
| SVG 2 features at risk | SVG | W3C flags multiple title or desc elements, nested links and some vector-effect options | Stay with SVG 1.1 features |
| APNG in older tools | PNG | Viewers without animation support show the static image | Test the toolchain, not only the browser |
Caniemail lists Apple Mail, Outlook and Yahoo! Mail as supporting SVG images, which leaves Gmail as the client that changes the file. Anything that must look exactly like the original in an inbox is safer as PNG.
Text is the usual casualty. SVG text that depends on a web font from a linked stylesheet falls back to a system font when the file is used as an image, because MDN states that external resources cannot load there.
The at-risk list comes from the SVG 2 Candidate Recommendation Snapshot of 6 October 2026, so the features could still be dropped. Single title and desc elements are not affected.
APNG fails in tools more often than in browsers. ImageMagick reads only the first frame of an APNG unless the apng: prefix is used, and it needs ffmpeg on the path for the rest.
Are SVG Files a Security Risk?
Yes, in one specific way. SVG is XML that can contain script, so a hostile file can run code once it is opened directly or inlined. A PNG has no script element, though OWASP lists parser exploits among upload threats for every image type.
Embedding in an img tag blocks the script, but opening the file’s URL directly does not. The code then runs under the site’s own domain, which exposes cookies and local storage, as the sanitize-svg project’s README explains.
PentesterLab’s SVG XSS glossary lists script tags and event handlers such as onmouseover, foreignObject elements carrying HTML (iframes included), uploads served with the wrong content type, and inline SVG built from user content.
A documented case involved FoF Upload, an extension for the Flarum forum software. An attacker’s JavaScript ran when someone navigated straight to an uploaded SVG, as long as SVG uploads were allowed.
GitHub’s advisory (CVE-2022-30999, published 25 May 2022) rates it High at CVSS 8.7. Version 1.2.3 fixed it by sanitizing uploaded SVG files.
A few defenses are worth layering.
- DOMPurify, from Cure53 and at version 3.4.14 on its repository, handles SVG through
USE_PROFILES: { svg: true }. Server-side it needs an up-to-date jsdom, and its maintainers warn that sanitized markup loses protection if code modifies it afterward. - Uploaded SVG should go out with
Content-Disposition: attachmentand a Content-Security-Policy, per PentesterLab. - OWASP’s File Upload Cheat Sheet says to keep uploads on a separate host and never trust the Content-Type header.
- When the vector isn’t needed, convert uploads to PNG. OWASP recommends re-encoding images but notes that rewriting does not guarantee all malicious content is removed.
Sanitizers cost features. Nextcloud’s IntraVox app, which uses the enshrined/svg-sanitize library, strips foreignObject elements and rejects any SVG with a DOCTYPE declaration, a guard against XXE attacks.
WordPress core does not allow SVG uploads by default, and the question is still being debated in Core Trac ticket 24251. Adding image/svg+xml through the upload_mimes filter only declares the type allowed, so it needs a sanitizer behind it.
A 2025 Trac ticket (63302) reported that SVG uploads failed in the block editor from WordPress 6.8 even when a custom filter allowed them, while the Media Library still worked. The fix shipped in WordPress 6.8.1. Test uploads after each core update.
How to Convert SVG to PNG and PNG to SVG
Going from SVG to PNG is rasterization, and it is exact at whatever size you pick. Going the other way means tracing, which only approximates pixels with paths and never restores the original vector source.
Converting SVG to PNG
Rasterizing commits the file to one pixel size, so choose the size first.
- Multiply the display size by the density you serve, then export at that pixel size.
- Render it with ImageMagick using
magick -background none -density 192 logo.svg logo.png. ImageMagick assumes 96 dpi for SVG, so 192 doubles the output, and-background nonekeeps the transparent canvas the SVG standard expects. - Check which renderer ran, because ImageMagick uses Inkscape when it is installed, then RSVG, then its internal MSVG renderer. Look over gradients and text in the result.
- Recompress the PNG with OptiPNG, which preserves every pixel.
Figma, Inkscape and ImageMagick all handle turning an SVG file into a PNG, and ImageMagick is the one to script.
Watch the security side too. OWASP cites ImageTragick among upload exploits and advises up-to-date builds along with restricted formats, resource limits and sandboxing. ImageMagick’s own documentation says entity substitution and huge-file parsing, along with embedding, are only for SVG sources you trust.
Converting PNG to SVG
Tracing swaps pixels for outlines, so the result is an interpretation of the PNG, not a recovery of the artwork.
Inkscape has integrated Potrace since release 0.40, which makes converting PNG to SVG a menu command for most designers. Potrace 1.16, released 17 September 2019, is the current version on its project page.
Potrace reads PBM, PGM, PPM or BMP files, not PNG, so convert first. Its bundled mkbitmap tool pre-processes greyscale and color images for tracing. For a BMP, the command is potrace --svg logo.bmp -o logo.svg.
The -t flag suppresses speckles up to a set size (default 2). -a sets the corner threshold (default 1), and -O the curve optimization tolerance (default 0.2).
Potrace traces one color at a time, so multicolor artwork needs a color tracer such as SVGcode, which the Potrace page lists as a web interface that can also trace color.
Keep the original SVG. A trace of a rasterized export cannot recover the clean geometry, and the raster step has already discarded detail.
SVG vs PNG FAQ
Can I serve an SVG with a PNG fallback?
Yes. Wrap both files in a <picture> element, with a <source type="image/svg+xml"> first and an <img> that points to the PNG.
Google’s image guidelines show this pattern and require the img fallback. MDN lists picture as available across browsers since March 2016.
Which format is better for image SEO?
Neither has an edge. Google Search supports PNG, SVG and five other formats in the src attribute of an img element, and its documentation (updated March 2026) names no preferred one.
Use an img element, since Google does not index CSS images, and add descriptive alt text. Inline SVG takes a title element instead.
Is SVG or PNG better for print?
For logos and line art, SVG wins, because it renders at any output resolution.
A PNG works only if it holds enough pixels for the print size. Its DPI tag is a hint stored in metric units, according to ImageMagick’s documentation, and the pixel count still decides sharpness.
Why does my SVG look blurry after exporting to PNG?
The export holds too few pixels for the display, so the browser stretches it.
ImageMagick renders SVG at 96 dpi by default, and its -size option is ignored when Inkscape is the renderer. Raise -density instead.
Which Images to Swap First on an Existing Site
On an existing site, the SVG vs PNG swap starts with logos and icons that ship as PNG, then moves on to flat-color diagrams and charts.
- Logo and icon PNGs used site-wide
- Diagrams and charts exported as PNG
- Photographic PNGs, which should move to WebP or AVIF instead
The order follows reach, since a header logo sits in every page template and one swap touches every URL. Deploy one group at a time and rerun PageSpeed Insights after each, which Google’s image guidance names for speed checks, so a change in load time traces to a single group.
The cost is two files per logo, an SVG for browsers and a PNG kept in sync for email. Move email assets up the list only once Caniemail shows Gmail rendering SVG natively (last tested 16 September 2026).
Logos with no vector original block the first swap, so start by making SVG files from the source artwork.
- What is Backend in Web Development? - September 13, 2026
- What is Frontend Development? - September 11, 2026
- How to Make a Button in Figma: Design Best Practices - September 10, 2026


