Formats
What is PNG, and why is it still everywhere?
PNG was designed in 1995 to replace GIF and avoid a patent. Three decades later it is still the format that websites reach for when exactness matters more than bytes.
At a glance
- PNG is a lossless format: encoded pixels decoded back are the same pixels that went in, exactly.
- A PNG file is a stream of chunks — IHDR, PLTE, IDAT, IEND and optionally metadata — rather than one opaque blob.
- Five colour types (greyscale, truecolour, indexed, and the two with alpha) combine with bit depths from 1 to 16 to make ten legal pixel formats.
- Transparency exists in two flavours: a real alpha channel in colour types 4 and 6, or a single transparent index via tRNS for indexed images.
Why the format exists
PNG (Portable Network Graphics) was created in the mid-1990s as a replacement for GIF, whose LZW compression was encumbered by patents and whose palette was limited to 256 colours. The design goals were straightforward: lossless compression, better compression than GIF, support for both palette and truecolour images, and transparency that worked properly.
The "lossless" claim is the part that matters most in daily use. Everything you encode into a PNG comes back out unchanged, bit for bit. That is why PNG is the format designers reach for when an image contains text, sharp edges or a logo that must not acquire JPEG artefacts — and why the same property makes photographs enormous in it.
A file made of chunks
A PNG is a sequence of chunks. Each chunk declares its length, a four-character type, its payload, and a CRC for integrity. The structure is simple enough to parse by hand, which is one reason the format has aged well.
| Chunk | Required? | What it carries |
|---|---|---|
| IHDR | Yes, first | Image width, height, bit depth, colour type, compression method |
| PLTE | For colour type 3 | The palette: 1 to 256 RGB entries |
| tRNS | Optional | Transparency information: an alpha per palette entry, or one transparent value for greyscale/truecolour |
| IDAT | Yes | The compressed pixel data, split across one or more chunks |
| IEND | Yes, last | End-of-file marker |
| Ancillary chunks | Optional | Text, timestamps, colour profiles, physical pixel dimensions, and more |
Ancillary chunks are why the same pixels can be stored in files of different sizes: text comments, EXIF-style metadata and colour profile data all ride along unless stripped.
Colour types and bit depth
The IHDR's colour type and bit depth together define how each pixel is stored. Ten combinations are legal in the current specification:
| Colour type | Meaning | Allowed bit depths | Channels per pixel |
|---|---|---|---|
| 0 | Greyscale | 1, 2, 4, 8, 16 | 1 |
| 2 | Truecolour (RGB) | 8, 16 | 3 |
| 3 | Indexed (palette) | 1, 2, 4, 8 | 1 index |
| 4 | Greyscale with alpha | 8, 16 | 2 |
| 6 | Truecolour with alpha (RGBA) | 8, 16 | 4 |
Two practical notes follow. First, a "screenshot" or a flat UI graphic is usually colour type 3 with a small palette and a low bit depth, which is why such files can be a few kilobytes — fewer bits per pixel and a highly repetitive index stream. Second, a logo that needs transparency is usually type 6 at 8 bits per channel, which is 32 bits per pixel before compression; that is where most of the size in an "unnecessarily large PNG" usually comes from.
Compression, in one paragraph
PNG compresses in two stages. Each scanline is first transformed by a filter that subtracts a prediction (the pixel to the left, above, above-left, and so on) so that smooth areas become runs of small numbers. The filtered bytes are then compressed with DEFLATE, a lossless algorithm that replaces repeated sequences with references into a 32 KB window. Choosing better filters and a better DEFLATE implementation is the entire basis of "PNG optimisation" tools.
Because every stage is lossless, the trade is purely size against time: a stronger deflate setting or a smarter filter search never changes a single pixel. That also means a PNG cannot be made losslessly smaller than its entropy allows — the only ways to cut it substantially are to change the pixels (reduce the palette, lower the bit depth, resize) or choose a different format.
Transparency, two ways
The commonly misunderstood part of PNG is that transparency is not one feature:
- tRNS chunk (indexed images). One palette entry is declared fully transparent. That yields hard edges only: a pixel is either opaque or invisible, with nothing in between. This is how the old GIF-style transparency maps onto PNG.
- Alpha channel (colour types 4 and 6). Every pixel carries its own alpha value with the same bit depth as the colour channels. Edges can be smoothly blended, which is what makes modern cutouts look clean.
Antialiased text and soft shadows need the second kind. Converting a soft-alpha image to indexed colour with a single transparent entry will harden every soft edge into a staircase — a common cause of "the transparency got worse after I saved it".
Animation, and where the format stands in 2026
APNG extends PNG with animation chunks (acTL, fcTL, fdAT) and is part of the current specification family. Non-animated decoders show the first frame, which makes APNG a graceful fallback: viewers that understand it animate, viewers that do not show a still image.
For static images the format remains competitive in specific cases rather than universally. Lossless formats beat lossy ones on flat colour, text and sharp edges; lossy formats win on photographic content by a wide margin. Our measured corpus makes the point: PNG output for a photograph was 1,106.8 KB where the JPEG equivalent at quality 85 was 140.3 KB, while for flat art the same comparison was 190.2 KB against 78.9 KB — a much smaller gap, and one that narrows further when a palette is used.
When PNG is the right answer
- Images containing text, thin lines or flat colour where any visible artefact is unacceptable.
- Anything that needs accurate transparency, especially soft edges and shadows.
- Intermediate editing steps where repeated lossy encoding would compound.
- Icons and UI assets, particularly with a small palette or a low bit depth.
And when it is not: photographs destined for the web, where a lossy format cuts the file by roughly an order of magnitude at quality levels most viewers cannot distinguish. The converter on this site handles the common case in both directions, entirely in your browser.
Sources
- W3C, PNG Specification (Third Edition) — https://www.w3.org/TR/png-3/
- W3C, Portable Network Graphics (PNG) Specification (Second Edition), chunk and filter definitions — https://www.w3.org/TR/PNG/
Convert WebP files to PNG or JPG — in your browser
Batch conversion, ZIP download, transparency kept. No upload.