JPEG and PNG are the two most common image formats on the web, and they are not interchangeable. They were designed for completely different jobs, and using the wrong one can multiply your file size tenfold or visibly destroy your image. The good news: the rule for choosing between them is simple, and once you've internalized it, you'll never have to think about it again.
The core difference: lossy vs lossless
Every image is a grid of pixels. The format you save it in determines how those pixels get stored on disk.
PNG is lossless. It stores every single pixel exactly as you set it. Open the saved file later, and you get back the same pixels, byte-for-byte. The tradeoff is file size: storing every pixel exactly takes a lot of space, especially for complex images.
JPEG is lossy. It analyses your image, decides which information your eye can't easily see (subtle colour shifts, fine details in busy areas), and discards that information to make the file smaller. The tradeoff is fidelity: you can't recover what was discarded. Re-save a JPEG five times and you'll see the quality slowly decay.
When to use JPEG
JPEG is the right choice when:
- The image is a photograph (or any continuous-tone image with smooth gradients and lots of subtly different colours).
- You don't need transparency.
- File size matters more than pixel-perfect fidelity.
- The image will be displayed at typical viewing sizes — not zoomed in 4× looking for compression artifacts.
Concrete examples: vacation photos, product photography for an e-commerce site, hero images on a marketing page, photos uploaded to social media. Anywhere you'd describe the image as 'a photograph,' JPEG is almost certainly the right format.
At quality 75 (a common default), JPEG typically produces files 80–90% smaller than the equivalent PNG, with no quality loss visible to the eye. That's not a small win — it's the difference between a fast page and a slow one.
When to use PNG
PNG is the right choice when:
- The image has sharp edges, hard lines, or solid blocks of colour (logos, icons, UI mockups, diagrams).
- You need transparency — JPEG simply doesn't support it.
- You're saving a screenshot of text, code, or a user interface.
- The image will be edited and re-saved multiple times. PNG's losslessness means no quality decay.
- You're working with pixel art, where every pixel must be preserved exactly.
Concrete examples: company logos, app icons, screenshots of code or dashboards, infographics, diagrams, chart exports, anything with text rendered as part of the image.
For these kinds of images, PNG often produces smaller files than JPEG would — because most of the image is one colour, and PNG's compression is excellent at runs of identical pixels. JPEG, meanwhile, would smear the sharp edges with visible noise.
Common mistakes
Saving photos as PNG
The single most common mistake. Someone takes a 4MB JPEG photo, opens it in an editor, exports as PNG, and ends up with a 28MB file that looks identical. The internet is full of accidentally-PNG photos. If your image is a photograph, save it as JPEG — your hosting bill (and your visitors' phone batteries) will thank you.
Saving logos and screenshots as JPEG
The opposite mistake. JPEG compresses sharp edges by smearing them with subtle noise. On a logo or a screenshot of text, that noise is highly visible and makes the image look cheap. Plus you lose any transparency. Always PNG (or SVG, if vector source is available) for graphics with hard edges.
Re-saving JPEGs repeatedly
Every time you open a JPEG and re-save it, more information is discarded. The original photo loses fidelity slowly with each save. If you'll be editing an image many times (say, designing in Photoshop), keep the working file in a lossless format (PNG, TIFF, or the editor's native format) and only export to JPEG for the final output.
Using PNG-24 when PNG-8 will do
Less common but worth knowing: PNG comes in two flavours. PNG-24 (with 16+ million colours and full alpha) is the default. PNG-8 (256 colours, palette-based) is dramatically smaller and perfect for icons, UI elements, and simple graphics. Most image editors hide this option, but it can save 70%+ on file size for the right kind of image.
Decision flowchart
When in doubt, ask yourself these questions in order:
- Does the image need transparency? → If yes: PNG.
- Is the image a screenshot, logo, icon, diagram, or graphic with sharp edges? → If yes: PNG.
- Is the image a photograph or a continuous-tone illustration? → If yes: JPEG.
- Will the image be edited and re-saved multiple times? → If yes: PNG (or another lossless format) for the working file.
- None of the above? → Default to JPEG. It's almost always the right choice for photographic content.
The bottom line
JPEG is for photographs. PNG is for graphics, screenshots, and anything that needs transparency. Picking the wrong one costs you either file size (PNG for photos) or visible quality (JPEG for graphics). The rule is simple, the consequences of getting it wrong are dramatic, and once you've internalized it you'll never have to think about it again.