For most of the web's history, a small image with a transparent background was a contradiction. JPEG was small but could not be transparent. PNG could be transparent but stored everything losslessly, so a product photo cut out of its background weighed several times what the same photo did as a JPG. WebP removed the trade-off with a simple structural decision: compress the color and the transparency separately, each in the way that suits it.
A WebP File Is a RIFF Container of Chunks
WebP is specified in RFC 9649, published by the IETF in 2024 after more than a decade as a Google document. The file is a RIFF container, the same chunk structure WAV audio uses: the bytes RIFF, a length, the bytes WEBP, then a sequence of chunks, each with a four-character name, a length and a payload.
Three layouts exist. A simple lossy file holds one VP8 chunk with the VP8 key frame. A simple lossless file holds one VP8L chunk. Anything more, whether transparency on a lossy image, animation, a color profile or metadata, uses the extended layout, which starts with a VP8X chunk whose flag bits announce what else is in the file. An alpha flag in VP8X, followed by an ALPH chunk and then the VP8 image data, is how a lossy WebP carries transparency.
The ALPH Chunk: Alpha on Its Own Terms
VP8 was designed for video and has no idea what transparency is. It encodes brightness and color only. So the alpha channel travels beside it in the ALPH chunk, as a plane of one byte per pixel, and its first byte describes how that plane is stored.
The compression method is either none or WebP lossless. The libwebp encoder uses lossless by default, which means the alpha decodes to exactly the values it was given. A filtering method can predict each alpha value from its neighbour to the left, above, or a gradient of both, the same idea PNG's filters use, before the lossless coder sees it. And an optional preprocessing step, level reduction, can quantize the alpha values to fewer levels to save space, which is the one lossy option for alpha and is off unless an encoder chooses it.
The result is a file where the colors may be approximated but the shape of the transparency is exact. An anti-aliased edge stays at precisely the opacities the artist drew. That matters more than it sounds: errors in color are hard to see, but errors in alpha show up as jagged or haloed outlines against whatever the image sits on.
Why the split works
Color in a photograph is full of noise that lossy compression can approximate invisibly. Alpha almost never is. A typical mask is large regions of 0 and 255 with a thin band of intermediate values at the edges, which is exactly the kind of data a lossless coder compresses to almost nothing. Each plane gets the method that suits it, and the alpha often adds only a few percent to the file.
Transparent Image Options Compared
Size figures from Google's published WebP comparison studies. Real results vary a lot with content.
| Format | Color | Alpha | Typical size |
|---|---|---|---|
| PNG (RGBA) | Lossless | Lossless | Baseline |
| Lossless WebP (VP8L) | Lossless | Lossless | About 26% smaller than PNG |
| Lossy WebP + ALPH | Lossy | Lossless by default | About a third of PNG |
| JPG | Lossy | None | Small, but no transparency at all |
Lossless WebP, and Why a Browser Rarely Writes It
WebP also has a fully lossless mode, VP8L, built from scratch rather than borrowed from video. It runs a sequence of reversible transforms over the image: a predictor transform with fourteen prediction modes chosen per tile, a color transform that removes correlation between channels, a subtract-green step, and color indexing for images with few colors. It then encodes with LZ77 back-references, a small cache of recent colors, and Huffman codes. Google measured it at about 26 percent smaller than PNG on the same images.
The catch is in how web pages produce images. A page encodes through canvas.toBlob(callback, "image/webp", quality), and the HTML specification leaves it to each browser what that quality number means. Chromium-based browsers switch to lossless VP8L at exactly 1.0, a behaviour added to Chromium in 2016 to match how its JPEG encoder treats maximum quality. The specification does not require it, and below 1.0 every browser writes lossy color with the alpha plane stored losslessly alongside. That is the right result for photographs and most graphics. For pixel art and screenshots that must stay exact, keep the PNG, or use a desktop encoder such as libwebp's cwebp -lossless where the result does not depend on the browser.
Convert PNG to WebP and keep the transparency
Quality 80 by default, the size saving on every file, and a full-size comparison against the PNG.
Where WebP Works, and the One Gap That Matters
Displaying WebP is now universal on the web. Writing it is not.
Every current browser displays it
Chrome has shown WebP since 2011, Edge since version 18 in 2018, Firefox since version 65 in 2019, and Safari since version 14 in 2020, fully on iOS from that release and on macOS from Safari 16.
Safari cannot encode it from a page
Ask a Safari canvas for image/webp and it returns a PNG, because it has no WebP encoder exposed to pages. The HTML specification requires a browser to fall back to PNG for any type it cannot write, so the call succeeds silently. A tool that does not check ends up saving a PNG named .webp.
Older software and email are the gaps
Some desktop programs, office suites and email clients still do not read WebP. For a web page that is irrelevant. For a logo you will also send by email, keep the PNG next to the WebP.
The picture element covers the rest
Serving <source type="image/webp"> inside a <picture> with the PNG in the <img> fallback lets each browser take the first format it understands, so nobody receives a file they cannot show.
Choosing a Quality for Graphics With Transparency
For photographic cut-outs, such as products, people and objects on a removed background, 75 to 80 gives files far smaller than PNG with no visible difference. The color is what is compressed, and color noise in a photograph hides compression well.
Logos, icons, text and interface elements are different. They are made of sharp edges and flat color, which is exactly what lossy compression smooths, and VP8 always stores color at half resolution, so thin colored strokes lose definition first. Use 90 or higher for these and compare at full size, looking at the smallest text. If the WebP is not meaningfully smaller than the PNG at a quality that keeps the edges clean, the PNG was already efficient and is the better file to ship.
Frequently Asked Questions
Related Tools
Keep Reading
PNG to JPG Without Black Backgrounds or Halos Around the Edges
Transparent pixels are stored as zero, which is black. The compositing formula behind every flattened logo, and the PNGs that should never become JPGs.
Serving WebP on Your Site: picture, Accept Headers and the Vary Trap
The picture element or server negotiation, and the one missing header that lets a cache hand WebP to everyone. Plus where the JPG should stay.
What the JPEG Quality Slider Is Really Doing to Your Photo
Quality 80 scales the quantization tables to 40 percent, it does not keep 80 percent of the picture. Where the setting stops being free, and why PNG has no dial.
Which Favicon Files a Browser Actually Requests
One .ico was enough in 1999 and thirty files is a 2015 habit. What each size is for, why ICO holds three images, and the five ways it goes wrong.