ScreenshotNeo

BlogGuides

Best Image File Formats for Websites

Choose JPEG, PNG, WebP, AVIF or SVG by image content, transparency, animation, browser support and delivery—not by one universal winner.

By the ScreenshotNeo team1 October 20268 min read

There is no single best image format for every website. Use SVG for simple scalable artwork, JPEG for broadly compatible photographs, PNG when you need lossless detail or transparency, WebP as a practical modern raster default, and AVIF when its smaller files and feature set justify testing your browser and delivery support. Always choose suitable dimensions and quality as well as a format.

This guide gives you a decision process, implementation patterns, fallback code, performance checks and troubleshooting steps.

1. Choose a format by image type

Image or requirement Recommended starting point Why Watch for
Logo, icon, diagram or UI artwork SVG Drawing instructions stay sharp at any size. Complex photographs are a poor fit for vectors.
Still photograph WebP, AVIF or JPEG fallback Lossy raster compression keeps photos practical to download. Inspect quality at the displayed size; JPEG has no transparency.
Transparent photographic or illustrated asset WebP or AVIF with alpha; PNG fallback These formats can preserve transparency with smaller files than many PNG exports. Confirm support in your target browsers and pipeline.
Pixel-perfect, lossless artwork PNG or lossless WebP Lossless compression preserves exact pixels. PNG can be substantially larger than lossy alternatives.
Animation Animated WebP or AVIF; sometimes APNG Modern animated image formats offer alternatives to GIF. For substantial motion, compare a video; GIF is limited to 256 colors and is often large.
HDR or wide-gamut image AVIF AVIF supports HDR, wide color gamut, alpha and animation. AVIF does not progressively render; the file appears after it has downloaded.

These capabilities are documented by MDN’s image format guide, web.dev’s format guidance and IETF RFC 9649 for WebP.

2. Format-by-format details

SVG

SVG stores geometric drawing instructions instead of a fixed pixel grid. It is usually the right choice for logos, icons, diagrams and interface illustrations that must remain sharp across sizes. Keep photographic scenes as raster images; a vector description of a photo can become unwieldy and still fail to look realistic.

JPEG

JPEG is a broadly supported lossy still-image format and remains a useful fallback for photographs or systems that explicitly require JPEG. It has no alpha channel, so it cannot carry transparent pixels. Test quality settings on the actual image instead of assuming one quality value fits every photo.

PNG

PNG uses lossless compression and supports transparency, making it useful for exact reproduction, screenshots with sharp edges, and assets that must retain alpha. It can be much larger than lossy formats. If your target browsers and tooling allow it, compare lossless WebP before shipping a large PNG.

WebP

WebP supports lossy and lossless compression, alpha transparency, animation, metadata and color profiles. The IETF defines it as a RIFF-based image format with lossless and lossy compression, alpha and animation. It is widely supported in modern browsers and is often a straightforward modern raster choice, but inspect every asset for artifacts.

AVIF

AVIF supports lossy and lossless compression, alpha, animation, HDR and wide color gamut. It can produce smaller files than older formats for some images and settings. Results vary by source image, encoder and quality value, so measure your own assets. AVIF has no progressive rendering: a large file is displayed only after the complete download.

GIF and other animation choices

GIF remains broadly compatible but is limited to 256 colors. For animation, compare animated WebP, AVIF and APNG, and consider <video> when the animation is long or large. A video can be much smaller than an equivalent GIF.

3. Serve modern formats with a fallback

Use <picture> when you want the browser to select the first supported source. Put shared alternative text and intrinsic dimensions on the nested <img>. Add srcset and sizes so the browser can avoid downloading an oversized candidate.

<picture>
  <source
    type="image/avif"
    srcset="/images/hero-480.avif 480w,
            /images/hero-960.avif 960w,
            /images/hero-1440.avif 1440w"
    sizes="(max-width: 700px) 100vw, 70vw">
  <source
    type="image/webp"
    srcset="/images/hero-480.webp 480w,
            /images/hero-960.webp 960w,
            /images/hero-1440.webp 1440w"
    sizes="(max-width: 700px) 100vw, 70vw">
  <img
    src="/images/hero-960.jpg"
    srcset="/images/hero-480.jpg 480w,
            /images/hero-960.jpg 960w,
            /images/hero-1440.jpg 1440w"
    sizes="(max-width: 700px) 100vw, 70vw"
    width="1440"
    height="900"
    alt="Description of the scene"
    decoding="async">
</picture>

The browser checks sources in order and uses the first supported matching type. Keep the fallback genuinely usable; do not assume every client supports AVIF or WebP.

4. Use HTTP content negotiation carefully

A server or image CDN can inspect the request’s Accept header and return an appropriate representation. If one URL can return different formats, send Vary: Accept so shared caches do not serve an AVIF response to a client that asked for JPEG.

HTTP/1.1 200 OK
Content-Type: image/avif
Vary: Accept
Cache-Control: public, max-age=31536000, immutable

Content negotiation reduces markup variants, but it adds cache and debugging complexity. Verify that your CDN keys on the negotiated header and that transformed variants have stable cache keys.

5. Size, quality and responsive delivery

  • Export candidates close to the largest display sizes you actually use. A 3000-pixel image shown at 600 pixels wastes transfer and decode work.
  • Use srcset and sizes for responsive images. Format conversion cannot compensate for unsuitable dimensions.
  • Compare visual quality at normal viewing size and at high-contrast edges. Lossy artifacts are especially visible around colored text, thin lines and flat backgrounds.
  • Set width and height (or an equivalent aspect-ratio box) to reduce layout shifts.
  • Use lazy loading for below-the-fold images. Do not lazy-load the image that is likely to be the page’s largest contentful paint candidate.
  • Cache immutable, versioned assets for a long time. If a URL is reused for changed bytes, purge or revalidate it.

Smaller WebP or AVIF files can reduce transfer time and may improve LCP when the image is the LCP candidate, but the gain depends on dimensions, quality, device and delivery path. Measure with representative pages and networks. HTTP Archive’s 2025 Web Almanac reported observed image-format shares of 29.1% JPEG, 27.2% PNG, 17.3% GIF, 13.9% WebP, 7.2% SVG, 3.4% AVIF and 0.9% other; treat those as that report’s snapshot, not a recommendation or timeless market share.

6. A practical implementation workflow

  1. Classify the source. Decide whether it is geometric artwork, a photo, a transparent asset, exact pixel art or animation.
  2. Pick a candidate set. Start with SVG for vectors; WebP or AVIF plus JPEG/PNG fallback for raster images.
  3. Generate responsive dimensions. Create only the widths your layouts need.
  4. Encode at several quality values. Compare byte size and visible artifacts on the real image.
  5. Implement fallback delivery. Use <picture> or correctly cached content negotiation.
  6. Measure the page. Check transfer bytes, decode time, LCP, layout stability and cache hit behavior on representative devices.
  7. Review accessibility. Write useful alternative text; do not put essential, searchable text inside a raster image.

7. Common errors and fixes

Problem Likely cause Fix
Transparent image has a solid background JPEG fallback or an encoder without alpha Use PNG, WebP or AVIF with alpha and test the fallback separately.
AVIF never appears Unsupported browser, incorrect MIME type or source ordering Serve image/avif, place it before WebP, and keep a working nested JPEG/PNG fallback.
Users receive the wrong format from cache Negotiated responses share a cache key Send Vary: Accept and verify CDN cache behavior.
Images look blurry on high-density screens Only one low-resolution candidate is available Provide larger srcset candidates while respecting display dimensions.
Page is still slow after conversion Oversized dimensions, render-blocking delivery or a slow origin Right-size candidates, prioritize the LCP image and inspect the full request waterfall.
Text in an image is unreadable Lossy compression or text embedded in a raster Use HTML text or SVG where appropriate; raise quality only after choosing the right representation.
Animation file is huge GIF’s limited palette and inefficient frame storage Compare animated WebP/AVIF or a video, and remove unnecessary frames.

8. Performance, reliability and cost notes

Format choice affects bytes, decoding and browser behavior, but it is only one part of image performance. Responsive dimensions, cache policy, preload decisions, CDN distance and origin latency can dominate. Keep a fallback path because a modern format’s smaller file is irrelevant if a browser or image pipeline cannot decode it. Avoid generating a needless matrix of every format and width; create variants justified by your layouts and measure their cache and storage cost.

For a site that publishes screenshots or other generated images, also account for capture reliability and wasted requests. A failed load, bot check or blank page should not become an expensive asset in your pipeline.

9. Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. It can return PNG, JPEG, WebP or PDF from one GET request, with options for full-page capture, lazy-image loading, element selectors, dark mode, device presets, retina scale, custom CSS and JavaScript, waits, request blocking, cookies, headers, user agents, geolocation, resizing, caching, signed links, async jobs and bulk capture. See the ScreenshotNeo API documentation for the complete option list.

curl -G "https://api.screenshotneo.com/v1/shot" \
  -d access_key=YOUR_API_KEY \
  --data-urlencode url=https://stripe.com \
  -o shot.webp
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({
  access_key: 'YOUR_API_KEY',
  url: 'https://stripe.com'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const data = Buffer.from(await res.arrayBuffer());
require('node:fs').writeFileSync('shot.webp', data);
  • Cookie and consent banners, newsletter popups and chat widgets are removed before the shot.
  • Bot checks, blank pages, failed loads, timeouts and cache hits are not billed; response headers report the page verdict and billing result.
  • An MCP server lets Claude, Cursor and other MCP clients call take_screenshot, get_page_info and capture_pdf.
  • The Free plan includes 1,000 screenshots each month with no card. Paid plans start at $5 for 3,000 screenshots; every feature is available on every plan.

Create a free ScreenshotNeo account and start with 1,000 screenshots a month at no charge.

10. FAQ

Should I use WebP or AVIF?

Test both on your actual images. AVIF may be smaller and supports HDR and wide gamut, while WebP is a straightforward modern choice with broad support. Keep a fallback where compatibility or infrastructure requires it.

Is PNG or JPEG better for a website?

JPEG is usually better for photographs when transparency is unnecessary. PNG is better for transparency or lossless, pixel-precise reproduction.

Use SVG when the logo is geometric and available as vector artwork. Use PNG, WebP or AVIF when the source is raster or contains effects that need pixels.

Which format loads fastest?

The smallest suitable file usually transfers fastest, but dimensions, quality, cache status, network and decoding also matter. Measure the complete page rather than choosing by extension alone.

Should every image have multiple formats?

No. Generate variants where they solve a browser, quality or performance need. A small icon may only need SVG; a photo may justify AVIF/WebP plus one fallback.