Responsive Image srcset and sizes Builder

Describe how wide your image is on each screen to get correct sizes and srcset, see which file each device loads, and make every width as a ZIP.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Enter the image

    Give the name, file pattern, original size and alt text.

  2. 2
    Describe the layout

    Add breakpoints with the slot width at each one, or type a sizes value.

  3. 3
    Choose widths

    Pick device needs, even steps or your own list, and the highest density.

  4. 4
    Set markup options

    Choose AVIF, WebP, fallback format, lazy loading or priority.

  5. 5
    Check the preview

    Use the slider and device table to see which file loads.

  6. 6
    Copy or make files

    Copy the markup, or open the original and download every width as a ZIP.

About this tool

Images are usually the heaviest part of a page, and the most common waste is a phone downloading a picture meant for a desktop monitor. The srcset and sizes attributes fix this, but only when both are right. srcset lists the available files with their pixel widths. sizes tells the browser, before any CSS has loaded, how wide the image slot will be at each viewport width, so it can multiply by the screen's pixel density and pick the smallest file that is sharp enough. Most mistakes come from sizes: leaving it out makes the browser assume the image fills the whole screen, and a guess that is too small makes images blurry on high-density phones. A second question is how many widths to produce; too few gives soft or bloated images, too many fills your storage and CDN cache. This builder works from your layout, calculates sizes, chooses widths from real device needs and shows what each device would download.

Layout rules to sizes

Describe the image slot for each breakpoint: a percentage of the screen, a percentage minus gaps such as calc(100vw - 32px) for a full-width image with page margins, or a fixed pixel width for wide screens. The builder sorts the rules and writes the sizes value. You can also type your own sizes value; the evaluator understands min-width and max-width media conditions in px or em, range syntax such as width <= 600px, and lengths in px, vw, em and rem with calc, min, max and clamp.

Choosing widths

Three strategies are offered. From real device needs computes the pixels each of ten common screens wants at the densities you serve, then merges widths within a tolerance you set, giving the fewest files that still look sharp. Even steps spreads a chosen number of widths geometrically between a minimum and a maximum. My own list takes the widths your image service already produces. Widths are capped at the original image width, and the highest density setting (1x, 2x or 3x) controls how far high-density phones are served.

Markup

The output has the sizes value, the srcset, a picture element with optional AVIF and WebP sources and an img fallback, and an img-only version. The img carries width and height so the page reserves space and does not shift, alt text, loading lazy for images below the fold, decoding async, and fetchpriority high with a matching preload link for a hero image.

Device preview and image files

Drag the viewport slider and choose a density to see the slot width, the width the browser wants and the file it should pick. A table lists ten devices with slot, need, the file they get and the extra pixels downloaded. The files tab resizes your original image in the browser into every width as JPEG, PNG or WebP, plus AVIF where the browser can encode it, and downloads a ZIP that follows your file pattern with a snippet.html included.

Limits

Browsers are allowed to choose differently, for example a smaller file on a slow connection or a larger one already in the cache, so the preview shows the standard choice. Canvas resizing is good for photographs but less crisp than dedicated tools for line art, and AVIF encoding depends on the browser. The tool does not measure your real CSS; if your layout changes, update the rules.

Worked example

A blog uses a 2400 by 1600 photo that fills the screen minus 32 px of margins on phones, half the screen up to 1024 px, and a fixed 600 px column on wider screens. The sizes value is (max-width: 640px) calc(100vw - 32px), (max-width: 1024px) 50vw, 600px. With density capped at 2x and a 15 percent merge tolerance, the device strategy chooses just 3 widths: 656, 796 and 1200. An iPhone 15 at 393 px gets a 361 px slot, needs 722 px and loads the 796 file; a 1366 px laptop needs 600 px and loads 656, 20 percent more pixels than needed; a MacBook Air at 2x loads 1200. The picture output has AVIF, WebP and JPEG sources with width 796 and height 531 on the img.

Quick facts

Frequently asked questions

Do I need sizes if I use srcset with w descriptors?

Yes. Without sizes the browser assumes 100vw, so on desktop a small column image downloads the largest file.

How many widths should I make?

Usually three to six. The device strategy shows the minimum set for your layout; more widths only save a few kilobytes each.

Should I serve 3x images to phones?

Many sites cap at 2x because the visible gain at 3x is small and the file is more than twice as large. The density setting lets you compare.

Why add width and height to a responsive image?

They give the browser the aspect ratio before the file loads, preventing layout shift. CSS width 100% and height auto keep it responsive.

When should I use the picture element?

Use picture with type sources to offer AVIF and WebP with a JPEG fallback, or with media queries for art direction. For one format, img with srcset is enough.

Is my image uploaded when I make the files?

No. Resizing uses canvas in your browser and the ZIP is built locally.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages