PNG is the default format for screenshots, logos, icons, UI mockups and anything with sharp edges or transparency. It is also the format most likely to bloat a project. A single full-screen retina screenshot can run to several megabytes, and a folder of exports can quietly add hundreds of megabytes to a repository or an app bundle. The good news is that PNG files are some of the easiest images to shrink, and you have two quite different ways to do it: one that guarantees identical pixels, and one that trades a tiny, usually invisible amount of color information for large savings.
This guide explains how both approaches work, when each is appropriate, which free and paid tools do the job offline, and how to check the result so you never ship an image that looks worse than the original.
Short answer
To compress a PNG with no quality loss, run it through a lossless optimizer such as oxipng, OptiPNG or ImageOptim, which rewrite the compressed data more efficiently and drop unneeded metadata. The pixels do not change. To go further, use a lossy PNG quantizer such as pngquant or the imagequant library, which converts the image to a limited palette. That is technically lossy, but on most interface graphics the difference is not visible to the eye.
How PNG compression works
Understanding the format makes it obvious why there is room to improve. A PNG is built from three ideas.
- Filtering. Before compression, each row of pixels is transformed using one of five filters that predict a pixel from its neighbors and store only the difference. Good filter choices make the data far more compressible.
- DEFLATE compression. The filtered data is compressed with the DEFLATE algorithm, the same family used in ZIP and gzip. Encoders can try harder or less hard to find repeated patterns.
- Chunking. The result is wrapped in chunks, which can include optional metadata such as text comments, color profiles, gamma values and timestamps.
Most image editors and screenshot tools save PNGs quickly, which means they pick a filter heuristically and use a fast compression level. A dedicated optimizer spends much more time, trying several filters per row and using a stronger DEFLATE implementation. The decoded pixels are identical, but the file is smaller.
Method 1: Lossless PNG optimization
Lossless optimization is the safe default. It cannot change what the image looks like, which makes it suitable for logos, brand assets, medical or legal imagery, and anything where an exact pixel match matters.
What it does
- Tries multiple filter strategies per row and keeps the best.
- Re-compresses with a more thorough DEFLATE encoder, for example Zopfli-style compression, which is slower but smaller.
- Reduces bit depth or color type when the image allows it, such as converting a 24-bit image that uses few colors to an indexed palette without any change in appearance, or dropping an unused alpha channel.
- Strips metadata chunks that do not affect rendering, such as text comments and timestamps.
What savings to expect
Lossless savings depend heavily on how the original was written. Files saved by a quick screenshot utility often shrink noticeably. Files that were already optimized shrink very little. Guides from vendors and tool authors commonly describe lossless savings in the range of roughly ten to thirty percent, but that is a rule of thumb, not a guarantee. Test on your own files and measure.
Tools
| Tool | Platform | Notes |
|---|---|---|
| oxipng | macOS, Windows, Linux (CLI) | Fast Rust optimizer, multi-threaded, good default for scripts and CI |
| OptiPNG | macOS, Windows, Linux (CLI) | Long-standing lossless optimizer, simple and predictable |
| ImageOptim | macOS | Free drag-and-drop app that wraps several optimizers |
| TinyPixels | macOS, Windows | Desktop app using oxipng for lossless mode, with batch and watch-folder support |
Method 2: Lossy PNG quantization
A normal true-color PNG can contain millions of distinct colors. A screenshot of a typical interface contains far fewer perceptually distinct ones: flat backgrounds, a few brand colors, anti-aliased text edges and some gradients. Quantization exploits that. It analyzes the image, chooses a palette of up to 256 representative colors, and stores each pixel as an index into that palette. The result is an 8-bit indexed PNG that is much smaller, usually with a bit of dithering to hide banding.
Because the palette is limited, the result is not pixel-identical to the original. That is why people call it lossy PNG compression. In practice, it is the technique behind well-known services and tools such as TinyPNG and pngquant, and it is the main reason those services can claim large reductions.
When quantization is safe
- UI screenshots with flat colors and text.
- Illustrations, icons and diagrams.
- AI-generated images and renders where small color shifts are not noticeable.
- Images with transparency, since quantized PNGs keep an alpha channel.
When to be careful
- Smooth gradients, such as sky or soft shadows, can show visible banding with a small palette.
- Photographs rarely suit quantization. JPEG, WebP or AVIF are better choices for photographic content.
- Brand logos with strict color requirements. A shifted shade of a brand color can matter, so stay lossless.
- Images you will edit again. Quantize only the final export, never the source file.
Tools
| Tool | Platform | Notes |
|---|---|---|
| pngquant | macOS, Windows, Linux (CLI) | Popular quantizer built on the libimagequant algorithm |
| libimagequant | Library | The quantization engine behind several apps and tools |
| TinyPNG / TinyJPG | Web | Cloud service; files are uploaded to its servers |
| TinyPixels | macOS, Windows | Desktop app using imagequant for lossy PNG, running 100% locally |
Which method should you choose?
| Situation | Recommended method |
|---|---|
| Logos, brand assets, legal or medical images | Lossless only |
| UI screenshots for docs, README files, app stores | Lossy quantization, then compare |
| Icons and sprites shipped in an app bundle | Lossy for large sets, lossless for tiny pixel-exact sprites |
| Photographs saved as PNG | Convert to JPEG, WebP or AVIF instead |
| Assets you will keep editing | Keep the original; optimize only the export |
Step-by-step: compress PNGs on your own machine
With a desktop app
- Copy the PNGs you want to shrink into a working folder so the originals stay untouched.
- Open your compression app and add the folder or the files.
- Pick lossless first. Note the size savings.
- Switch to lossy quantization for the files where you want more savings.
- Open the original and the compressed version side by side at 100% zoom, and look at gradients, text edges and transparent areas.
- Keep the version that passes your eye test and delete the rest.
With the command line
For scripted workflows, oxipng and pngquant are the usual pair. A typical pattern is to run quantization first and a lossless pass after, since the lossless step squeezes the indexed file further.
# lossy: reduce to a limited palette
pngquant --quality=70-90 --ext .png --force images/*.png
# lossless: optimize the result
oxipng -o 4 --strip safe images/*.pngThe flags above are an example. Check the documentation for your installed version, and always run on a copy first.
How to verify the result
Never trust a percentage on its own. A file that dropped sixty percent in size is a failure if the logo color shifted. Use a short checklist for every batch.
- Look at the compressed image at 100% zoom, not scaled to fit the window.
- Check gradients and shadows for banding, and text edges for color fringing.
- Check transparent areas against both a light and dark background.
- Confirm the pixel dimensions are unchanged.
- If the stakes are high, compare the images numerically with a tool that reports a difference metric such as SSIM or PSNR.
Reduce the size before compressing
The biggest saving is often not about the encoder at all. A 3000 × 2000 PNG that is shown in a 600 pixel wide slot carries more than twenty times the pixels it needs. Resize to the largest size you will actually display, plus an allowance for high-density screens, and then compress. The same applies to retina screenshots: if your documentation shows them at half width, export them at the pixel size you use.
Consider a different format
PNG is the right choice for lossless images with sharp edges and transparency, but it is not always the smallest. For web delivery, WebP and AVIF often produce smaller files than PNG at comparable visual quality, and both support transparency. Our PNG versus WebP comparison covers when the switch makes sense and how browser support affects the decision. If you ship to modern browsers only, converting a hero image from PNG to WebP or AVIF can save more than any amount of PNG tuning.
Privacy: why local compression matters for PNGs
PNG is the format of screenshots, and screenshots are where sensitive information hides: dashboards, customer records, internal tools, unreleased features. Cloud compressors upload the file to a remote server and promise to delete it later, which you cannot verify. A local tool processes the file on your machine and sends nothing anywhere. If you want to know more, our guide on whether it is safe to upload images to online compression tools covers the retention and compliance angles in detail.
TinyPixels is built around that idea. The compression engine runs as a native binary on your Mac or Windows PC, supports lossless and lossy PNG modes, batches whole folders, and can watch a directory and compress new files as they appear. Pro is a one-time purchase with no subscription.
Common mistakes
- Compressing a PNG repeatedly. Lossless passes are safe to repeat, but each lossy pass can reduce quality further. Always start from the original.
- Using lossy quantization on a photograph and judging the format instead of the content.
- Optimizing the source file instead of an export, and losing the editable original.
- Forgetting metadata. Color profiles matter for print and some design workflows, so strip metadata only when you do not need it.
- Judging quality at fit-to-window zoom, where most artifacts are hidden.
Batch workflows for teams
Single-file tips matter less than a process the whole team follows. Agree on one folder structure where originals live, such as a design-exports directory, and one where optimized files go. Run the optimizer on a schedule or on save rather than relying on memory, and review a handful of outputs at full size after any change to the settings so a bad preset does not silently degrade a whole release.
Document the settings in the repository README: which files get lossless treatment, which get lossy treatment and what quality target applies. New contributors then produce consistent results instead of guessing, and reviewers know what to look for in a pull request that touches images.
Conclusion
You do not have to choose between small and good. Start with lossless optimization for a guaranteed, zero-risk win. Add lossy quantization where your content allows it, and check the output at full size. Reduce pixel dimensions before you compress, consider WebP or AVIF for the web, and keep the process on your own machine for anything sensitive. With that workflow, most PNG-heavy projects get dramatically lighter without anyone noticing a difference.
Frequently asked questions
Can you compress a PNG without losing quality?
Yes. Lossless PNG optimizers such as oxipng, OptiPNG and ImageOptim re-encode the file with better filtering and compression and strip metadata, producing identical pixels in a smaller file.
How much can lossless PNG compression save?
It varies. Files saved by quick screenshot tools often shrink noticeably, while already-optimized files barely change. Test on your own images and measure the result.
Is lossy PNG compression visible?
Often not. Quantization reduces the image to a palette of up to 256 colors, which is hard to spot on flat interface graphics and illustrations but can show banding on smooth gradients and photographs.
Why are my PNG screenshots so large?
PNG stores every pixel losslessly, and retina screens produce high pixel counts. Screenshot tools also save quickly with modest compression, leaving room for optimizers to shrink the file.
Is it safe to compress PNGs with online tools?
Online tools upload your image to a server. For screenshots with sensitive content, a local tool is safer because the file never leaves your machine.
Should I convert PNG to WebP instead?
For web delivery, often yes. WebP and AVIF can be smaller than PNG at similar visual quality and support transparency. Keep PNG where you need lossless fidelity or broad compatibility.