Yes, you can compress PNG without losing transparency. The tools that shrink a PNG the most, palette quantizers like pngquant, work on color depth and leave the alpha channel completely alone, often cutting file size by as much as 70 percent. The one move that actually destroys transparency is converting the file to JPEG, a format that has no alpha channel to begin with.
I build the PNG compressor on this site, so this is not a guess about which flags are safe, it is what I see when I read the bytes. PNG is the only mainstream format that stores full per-pixel alpha, every pixel from solid to invisible, and that data survives compression fine as long as you stay in a tool built to respect it. PNG explained covers the format end to end. This page does one narrower job: it shows which methods keep transparency, the byte math for why fewer colors does not break it, and the single conversion path that wrecks it for good.
Can you compress PNG without losing transparency?
Yes. Every optimizer built for PNG changes color depth or file packing while leaving the alpha channel, the per-pixel transparency data, untouched. You lose transparency only when a tool steps outside PNG: converting to JPEG, flattening the image onto a background color, or exporting with the alpha channel switched off. Pick a PNG-aware compressor and transparency is never what gets traded away for size.
The table below is the whole decision in one glance. The rest of this page explains the mechanism behind each row, with the arithmetic worked out, so you know which lever you are pulling before you pull it.
| Compression path | Keeps transparency? | Typical size cut |
|---|---|---|
| Palette quantizer (pngquant, web tools) | Yes, full per-pixel alpha | Up to about 70% |
| Lossless optimizer (oxipng, ImageOptim) | Yes, every pixel unchanged | Smaller, no visible change |
| Convert to WebP (lossless or lossy) | Yes, alpha in both modes | Often beats PNG on the same file |
| Convert to JPEG | No, alpha is discarded | Small file, transparency gone |
If you just want the cut without installing anything, run the file through the PNG compressor and read the byte count before and after. The lossless pass it runs never touches a pixel's alpha, so the transparency you upload is the transparency you download.
How PNG transparency actually works
PNG stores transparency as an alpha channel: a value attached to every pixel that says how much of the background shows through, from 0 for fully invisible to 255 for fully solid. That per-pixel control is what lets a logo with soft, anti-aliased edges sit cleanly on any color behind it, instead of carrying a hard rectangular border. PNG is the only widely supported format that can store partially transparent images this way, which is exactly why designers ship logos and icons as PNG in the first place.
The alpha channel and the tRNS chunk
There are two mechanisms at play. Truecolor-plus-alpha PNGs carry a full 8-bit alpha sample for every pixel, stacked on top of the red, green, and blue samples, which is where the "32 bits per pixel" figure comes from. Lighter PNGs instead use a tRNS chunk, a small side table that marks either one single color as transparent or supplies alpha values for palette entries. Both are part of the format itself, not an add-on, so any reader that understands PNG understands them (the PNG spec).
Palette entries can carry their own alpha
Here is the fact most people miss: in indexed color mode, where a PNG stores up to 256 chosen colors in a palette, each palette entry can carry its own 8-bit alpha value alongside its red, green, and blue. That means a reduced-color PNG is not forced to be opaque. A 256-slot palette can hold 200 solid colors and 56 partly transparent ones, or any mix the image needs. This is the structural reason color reduction and transparency are not in conflict, and it is what the palette compressors below exploit.
Why do some tools destroy a PNG's transparency?
Converting a transparent PNG to JPEG is the single most common way to lose transparency, because JPEG has no alpha channel at all; it stores only red, green, and blue for every pixel (a Stack Overflow answer). Run a logo through a JPEG converter looking for a smaller file, and whatever was transparent gets filled with a solid color, usually white or black, baked permanently into the pixels with no way to lift it back out.
Silent auto-conversion on upload
Some platforms do this without asking. Certain upload pipelines convert incoming transparent PNGs to JPEG automatically to save server storage, which is why a logo that looked perfect on your machine sometimes comes back with a white box around it. That is a platform decision, not damage you caused, and the fix is usually a format setting in that platform rather than anything you do to the file. If a tool's only trick for shrinking a PNG is changing the extension to .jpg, it is not compressing your image, it is replacing it.
Flattening and exporting without alpha
The other two ways to lose transparency happen inside an editor. Flattening merges every layer onto a single background, which fills the transparent regions with whatever color sits behind them. Exporting with the alpha channel unchecked, an option some editors bury in their export dialog, does the same thing more quietly. If you do have a real reason to drop transparency, convert PNG to JPG the deliberate way so you know exactly what you are giving up, rather than discovering it after the fact.
How does transparency survive color reduction?
Transparency survives color reduction because the alpha values live inside the palette, not in a separate layer that quantizing throws away. A quantizer like pngquant works in premultiplied alpha color space, which gives less weight to mostly transparent colors while it picks its palette, so it does not waste one of its slots on a shade that barely shows through. Its output "reduces file sizes significantly (often as much as 70 percent) and preserves full alpha transparency," and it stays compatible with every browser and operating system (pngquant).
The byte math, worked out
The raw arithmetic shows why the real-world result lines up so cleanly. A truecolor-plus-alpha pixel costs 4 bytes before any compression runs, one each for red, green, blue, and alpha. An indexed pixel that points at a palette entry, alpha included, costs 1 byte. Take a 512 by 512 icon, which is 262,144 pixels: that is about 1.05 MB raw as truecolor-plus-alpha, and about 262 KB raw as an 8-bit indexed palette, a 75 percent cut before DEFLATE, the lossless packing step every PNG runs, has even started. That is the same lever pngquant pulls when it reports cutting an already-compressed file by up to 70 percent: fewer bytes per pixel, with the alpha carried inside the palette entry instead of stripped out.
The chart puts the per-pixel storage cost of each PNG mode side by side. The takeaway is the short green bar: a palette PNG that still carries alpha stores each pixel at 8 bits, a quarter of full RGBA's 32, and JPEG is the only bar on the board that keeps nothing transparent at any depth.
| PNG storage mode | Bits per pixel | Transparency |
|---|---|---|
| Truecolor with alpha (RGBA) | 32 | Full per-pixel alpha |
| Grayscale with alpha | 16 | Full per-pixel alpha |
| Indexed palette with palette alpha | 8 | Per-entry alpha, kept |
| JPEG (for contrast, not a PNG) | 24 | None, discarded |
Which tools keep transparency, and which do not?
The tools that keep transparency all share one habit: they touch color depth or file packing, never the alpha channel itself. The table sorts the common options by how they work, so you can match the method to how much you are willing to change.
| Tool or method | Type | Alpha survives? | Why |
|---|---|---|---|
| pngquant | Lossy palette (CLI, ImageOptim, Pngyu, PNGoo) | Yes | Quantizes in premultiplied alpha space; keeps per-pixel alpha in palette entries |
| Web palette tools | Lossy palette (drag and drop) | Yes | Same quantization approach; output stays an alpha-carrying PNG |
| oxipng | Lossless (CLI) | Yes | Repacks identical pixels more efficiently; changes no visible pixel |
| Save for Web PNG-8 | Palette export (editors) | Yes, with dithered or 1-bit alpha | Palette export that keeps a transparency table |
| Convert to WebP | Lossy or lossless | Yes | WebP has its own alpha channel in both modes |
| Convert to JPEG | Format change | No | JPEG stores no alpha; transparent pixels get filled |
pngquant and web palette tools (lossy, deepest cut)
pngquant is the workhorse for making a transparent PNG small. It reduces the color count intelligently and keeps every transparent and semi-transparent pixel, which is why it is the engine inside a lot of the drag-and-drop web compressors too. If you want to reduce PNG file size as far as it will go while keeping a clean edge on a logo, this is the method that gets you there, and it is worth comparing the front-ends in the best PNG compressors compared before you settle on one.
oxipng and ImageOptim (lossless, no visible change)
When you cannot afford to change a single visible pixel, reach for a lossless optimizer instead of a quantizer. oxipng is a lossless PNG and APNG optimizer that repacks the exact same pixels more compactly. Its optional --alpha flag improves compression by recoloring pixels that are already fully invisible, a change with zero visual effect since nothing shows through them, and everything else it does is strictly lossless (oxipng).
Can you compress PNG without losing quality, not just transparency?
Yes, and that is exactly the lossless lane above. A lossless optimizer like oxipng or ImageOptim changes nothing you can see, alpha included, so you compress PNG without losing quality at all, you just get a smaller, pixel-identical reduction than a palette quantizer gives. The rule of thumb: quantize when size matters most and a tiny edge change is acceptable, stay lossless when the file must be pixel-identical.
How to compress a transparent PNG, step by step
Start from a real PNG and work down in order, checking the edges at the end.
- Start with the right file. If the image was already flattened or saved to JPEG, the transparency is gone for good, so go back to a layered source, a PSD, an SVG export, or the original design file, and export a fresh PNG.
- Quantize first if size is the priority. Run
pngquant image.png, or set a floor withpngquant --quality=65-80 image.png. Below that minimum pngquant refuses to save and exits with status 99, forcing a bigger file rather than a visibly worse one. - Or use a browser tool instead of the command line. A drag-and-drop palette compressor does the same quantization job with no install, which is enough for most single logos and icons.
- Chain a lossless pass afterward. Running
oxipng -o 4 --strip safe --alpha *.pngbehind pngquant squeezes out leftover packing overhead without changing a visible pixel. - Check the edges at 100 percent zoom before you ship. Quantization can occasionally leave a faint band around a soft drop shadow or a gradient fade, since fewer alpha values remain to describe a smooth transition.
When should you switch to WebP instead of PNG?
Switch to WebP once you have quantized a PNG as far as it will go and still want it smaller. WebP supports full alpha transparency in both its lossless and lossy modes, and its lossless mode competes directly with pngquant, often winning on the same file, which is why it is a sound next step when PNG has run out of room (MDN's image format guide). The tradeoff is reach, not transparency: modern browsers and editors read WebP fine, but some older tools and print workflows still expect a plain PNG, so keep a PNG copy on hand if you are not certain where the file is headed.
When keeping a PNG is the wrong call
Converting to JPEG makes sense in exactly one case: you genuinely no longer need the transparency. A logo destined for a fixed white background, for example, does not need an alpha channel, and a JPEG at quality 80 will be far smaller than the PNG. Outside that narrow case, JPEG bakes a background color into every transparent pixel permanently, so the safe habit is to keep an untouched PNG copy before you convert anything, and to convert only when you are sure the transparency is not coming back.