Best Image Format for Websites

Choose the right web image format for photographs, transparent graphics, logos, screenshots, animation, and browser fallbacks.

By TinyImageFormats9 min read
In this guide
  1. Choose by asset type
  2. Photographs: test AVIF, WebP, and JPG
  3. Screenshots and diagrams: start with PNG
  4. Transparent images: alpha support is only the first check
  5. Logos and icons: keep vectors as vectors
  6. Use <picture> when alternatives earn their keep
  7. Dimensions can matter more than the codec
  8. A repeatable format-selection process
  9. Frequently asked questions

There is no single best image format for every website asset. For photographs, start by testing AVIF or WebP with a JPG fallback. Use PNG for lossless screenshots and raster graphics that need transparency. Use SVG for genuine vector logos and icons. Choose animation only when motion adds value, then compare an animated image with a video-based alternative.

Format is only one part of delivery. An image with the right codec can still be wasteful if its pixel dimensions are far larger than the layout, and a very small file can still be wrong if text is unreadable or transparency disappears. The best format is the one that meets the asset's visual requirements and works throughout your browser, CMS, CDN, and editing workflow.

Choose by asset type

Website assetStrong starting choiceWhyWatch for
Hero or editorial photographAVIF or WebP, with JPG fallback where neededModern lossy compression suits continuous-tone imageryOversized dimensions and excessive encoder quality
Product photoWebP, AVIF, or JPGGood fit for texture and color variationFine labels, shadows, and marketplace compatibility
UI screenshotPNGLossless storage protects small text and hard edgesLarge dimensions and photo-heavy regions
Transparent raster graphicPNG, WebP, or AVIFAll can represent alpha transparencyTool support and halos around semi-transparent edges
Logo or simple iconSVG when a vector original existsScales without rasterizing a fixed pixel gridUntrusted SVG content and unnecessarily complex paths
Simple short animationAnimated WebP, GIF, or AVIF after testingImage formats can be convenient for small loopsFrame count, dimensions, color needs, and file size
Download or partner feedFormat required by the recipientCompatibility is part of correctnessConverting only for fashion rather than a real need

The MDN image format guide documents the capabilities and compatibility of common web formats. Because support changes, check its current tables when an older browser, embedded webview, or non-browser consumer matters.

Photographs: test AVIF, WebP, and JPG

Photographs contain gradual changes in color and detail, so lossy compression is normally appropriate for delivery. AVIF and WebP are modern options; JPG remains a useful fallback and is still common in editing tools, feeds, documents, and external platforms.

Do not choose based on an extension alone. Export candidates from the same original at identical dimensions. Inspect skin texture, hair, foliage, text on products, dark areas, and smooth skies. Keep the smallest file that meets the visual target and the compatibility requirements.

The web.dev format decision guide recommends basing the choice on the image content and the browsers that need to display it. If you need a deeper comparison of the two modern formats, read WebP vs AVIF.

TinyImage can create supported alternatives through its image converter. Keep the original master so each delivery format is encoded from a clean source rather than from another lossy derivative.

Screenshots and diagrams: start with PNG

PNG is usually the safer first choice for screenshots, charts, interface captures, and diagrams. Its lossless compression preserves the encoded pixels, which protects small lettering, one-pixel borders, and sharp color transitions. The W3C PNG specification defines PNG's lossless image representation and alpha support.

PNG can become inefficient when a screenshot contains a large photograph, textured background, or noise. Before changing formats, crop empty space and resize the capture to the largest useful display size. Then try PNG compression, noting that TinyImage may reduce the palette to find a smaller result. Inspect colors, transparency, and text; if the file remains too large, compare WebP or AVIF at 100% zoom.

JPG is rarely the first choice for a code sample or settings dialog. Its lossy artifacts can gather around characters, making a modest file-size saving a poor trade.

Transparent images: alpha support is only the first check

PNG, WebP, and AVIF can all represent transparency. The choice depends on the content and the software path:

  • Use PNG for a dependable lossless raster asset or when the editor and recipient expect PNG.
  • Test WebP for transparent web graphics when the publishing stack supports it cleanly.
  • Test AVIF when its compression or color capabilities create a measured benefit.
  • Prefer SVG when the asset is truly vector-based and the source can be published safely.

Inspect semi-transparent shadows and anti-aliased edges against both light and dark backgrounds. A clean edge on a white checkerboard preview can reveal a halo once the page theme changes.

Logos and icons: keep vectors as vectors

An SVG describes shapes rather than a fixed grid of pixels, so a properly authored logo or icon can scale across densities without exporting several raster sizes. The MDN SVG documentation covers SVG's role as a web vector format.

Do not trace a detailed photograph into SVG or wrap a large embedded raster image in an SVG file. That changes the container without gaining the usual vector benefits. For user-supplied SVG, review sanitization and content-security requirements before allowing it into a page.

When only a raster logo exists, PNG is a sensible fallback. Export it at the required sizes and preserve transparency if the logo appears on several backgrounds.

Use <picture> when alternatives earn their keep

The <picture> element allows ordered format sources with an img fallback. Browsers evaluate the source elements and use the first suitable candidate; the MDN <picture> reference covers the selection model.

<picture>
  <source
    type="image/avif"
    srcset="/media/team-960.avif 960w, /media/team-1600.avif 1600w"
    sizes="(max-width: 700px) 100vw, 50vw"
  >
  <source
    type="image/webp"
    srcset="/media/team-960.webp 960w, /media/team-1600.webp 1600w"
    sizes="(max-width: 700px) 100vw, 50vw"
  >
  <img
    src="/media/team-1600.jpg"
    srcset="/media/team-960.jpg 960w, /media/team-1600.jpg 1600w"
    sizes="(max-width: 700px) 100vw, 50vw"
    width="1600"
    height="1067"
    alt="The support team working around a conference table"
  >
</picture>

This example separates two decisions: format selection and responsive width selection. It also keeps a real img fallback with dimensions and alternative text. Generate only the variants your layout and traffic justify; unused renditions add storage and maintenance work.

Dimensions can matter more than the codec

A 2,400-pixel image sent into a 600-pixel slot contains four times the displayed width and sixteen times the displayed pixel area. A modern format does not excuse that mismatch.

Resize source images for the layout, provide responsive candidates, and include intrinsic width and height. The web.dev image performance guide explains how transfer size, loading priority, responsive images, and layout stability fit together.

Use the TinyImage website analyzer to find heavy raster assets on a public page, then prioritize the images that create the largest practical opportunity. Measure the page again after changing delivery rather than assuming a format rename solved the problem.

A repeatable format-selection process

  1. Classify the asset. Is it a photo, screenshot, vector illustration, transparent overlay, or animation?
  2. Record hard requirements. Note transparency, exact pixels, HDR, animation, recipient rules, and supported browsers.
  3. Set delivery dimensions. Use the largest size the layout actually needs and create responsive widths where appropriate.
  4. Export credible candidates. Start each encode from the same master.
  5. Inspect important regions. Compare at the rendered size and at 100% around fine detail.
  6. Check the whole workflow. Confirm the CMS, CDN, browser, preview crawler, and download consumer handle the choice.
  7. Measure the result. Compare delivered bytes and page behavior, not only the file sitting on your computer.

Frequently asked questions

Is WebP or AVIF the best format for all website images?

No. Both are strong delivery formats, especially for photographs, but screenshots, vector logos, editing masters, animations, and external feeds have different requirements. Choose per asset class and keep fallbacks where the audience needs them.

Should I replace every PNG with WebP?

Only after testing. A transparent graphic or photo-heavy PNG may shrink usefully, while a small flat PNG may already be efficient. Keep PNG when lossless pixel reproduction or downstream compatibility matters.

Is JPG obsolete for websites?

No. JPG remains a useful fallback and delivery format, especially when external tools or platforms require it. It is less capable than WebP or AVIF in areas such as transparency, but compatibility is a legitimate requirement.

Use a safe, properly authored SVG when a vector original exists. Use PNG when you need a raster fallback with transparency. JPG is unsuitable for a logo that must preserve transparency or very sharp edges.