SquishPixel Blog · Guides

How to convert PNG to WebP, and when not to

WebP does everything PNG does on a web page, including transparency, in a smaller file. For most websites converting is an easy win. There are a few cases where it is the wrong move, and they are listed further down.

What you gain

WebP has two modes, and both support transparency:

  • Lossless WebP keeps every pixel exactly, as PNG does, and usually comes out smaller. Google, which develops the format, puts the typical saving at about a quarter.
  • Lossy WebP discards detail you are unlikely to see, as JPEG does, but can still carry a transparent background. For photographic PNGs, such as product cut-outs, the result is often a small fraction of the original size.

Every current major browser displays WebP, including Safari since version 14 in 2020.

Lossless or lossy?

Your PNG isChooseWhy
A logo, icon or diagram with flat colourLosslessEdges stay exactly as drawn, and flat colour already compresses well
A screenshot with textLossless, or lossy at a high qualityLossy WebP can soften small coloured text
A photo, or a photo with the background removedLossyThe saving is large and the loss is hard to see

The reason for the caution with text: lossy WebP always stores colour at half the resolution of brightness. On photos this is invisible. On thin coloured lines and small coloured lettering it can blur the edge.

How to convert

  1. Start from the original PNG, not a copy that has already been compressed.
  2. Open a converter. SquishPixel's PNG to WebP converter runs in your browser and does not upload the file.
  3. Add the PNG and choose a quality setting. Higher settings keep more detail and give a larger file.
  4. Compare the result with the original at full size. Look at edges, text and any soft transparent border.
  5. Download the WebP and replace the PNG on your page. Keep the same width, height and alt attributes.

If you have to support very old browsers, offer both files and let the browser choose:

<picture>
  <source srcset="logo.webp" type="image/webp">
  <img src="logo.png" alt="Company logo" width="240" height="80">
</picture>

When to keep the PNG

  • The image is going into an email. Support for WebP in email programs is patchy, and some desktop versions of Outlook do not show it at all. Use PNG or JPEG.
  • It is a link preview image. Not every service that builds a preview from og:image reads WebP. JPEG and PNG work everywhere.
  • Someone will open it in other software. Print shops, older design tools and some upload forms still expect PNG or JPEG.
  • It is your working file. Keep a lossless master in PNG, or in your design tool's own format, and export WebP copies from it. Saving a lossy file again and again degrades it.
  • It should be an SVG. A simple logo or icon drawn as shapes is smaller than either format and sharp at any size.
  • It is more than 16,383 pixels on a side. That is the limit of the WebP format.

Check the result

A converted file is not guaranteed to be smaller. A tiny PNG with a handful of colours that has already been well optimised can come out about the same size. If the saving is negligible, keep the PNG and move on to an image where it matters.

Photos saved as PNG are the opposite case and the best place to start. If your site has any, converting those to lossy WebP will do more than everything else on this page.