Responsive Image Srcset Calculator
Plan a responsive image set: the widths to generate, their heights at your aspect ratio and the total storage cost.
Everything you type here is processed on your own device. No input is sent to a server, logged, or stored.
What the Responsive Image Srcset Calculator does
The responsive image srcset calculator on this page will plan a responsive image set: the widths to generate, their heights at your aspect ratio and the total storage cost. Fill in all 6 fields and the result updates as you type — there is no Calculate button to press and no page reload. It is most often used for deciding which image widths to generate in a build pipeline. If you want to cross-check the result, there is another responsive image srcset calculator on FreeToolsWorld.org.
How to use it
- Enter the largest and smallest widths your layout will display the image at.
- Choose how many variants to generate — three to five suits most sites.
- Set the aspect ratio so the heights come out right for your crop.
- Copy the srcset attribute, then write a sizes attribute to match your own CSS.
How it works
A srcset lets the browser pick an image sized for the space it has, which is the single most effective image optimisation on most sites: a phone displaying a 400-pixel-wide image has no use for the 1600-pixel version, and serving it wastes roughly fifteen times the bytes. The attribute lists each file with its intrinsic width using the w descriptor, and the browser chooses using the displayed size, the device pixel ratio and sometimes the network conditions.
The number of variants is a trade-off rather than a target. More variants mean a closer fit and fewer wasted bytes, but also more files to generate, store, deploy and purge from a CDN. Three to five is where most sites land, and the spacing advice on this page flags the two failure modes: variants so far apart that small screens overshoot badly, and variants so close together that the extra build cost buys a saving nobody can measure.
The sizes attribute is the piece srcset cannot work without and this calculator cannot supply, because it depends on your CSS. srcset tells the browser how wide each file is; sizes tells it how wide the image will be displayed at a given viewport. Without sizes the browser assumes the image fills the viewport width — 100vw — and will usually download something larger than needed. If your image sits in a 720-pixel content column, sizes="(min-width: 760px) 720px, 100vw" is the kind of value that belongs there.
High-density displays are why the largest variant should exceed your largest layout size. A 2× display showing an 800-pixel-wide image wants 1600 actual pixels, which is what the retina row calculates. In practice diminishing returns set in fast above 2×, and most sites cap there rather than generating 3× assets, because the file size grows with the square of the scale factor while the visible improvement does not.
When to use it
- Deciding which image widths to generate in a build pipeline.
- Writing a srcset attribute for a responsive image.
- Estimating the storage cost of a responsive image set.
- Working out the pixel width needed for a high-density display.
Common mistakes to avoid
- Shipping srcset without a sizes attribute. The browser then assumes the image spans the viewport and picks one that is too large.
- Generating a dozen variants a few pixels apart, which multiplies build and storage cost for no measurable gain.
- Capping the largest variant at the layout width, which leaves high-density displays with a soft image.
Frequently asked questions
How many srcset variants should I generate?
Three to five covers most layouts. The goal is that no device downloads an image dramatically larger than it displays; past about five variants the extra files cost more in build time and storage than they save in bandwidth.
What is the difference between srcset and sizes?
srcset declares how wide each file is. sizes declares how wide the image will be displayed at a given viewport width. The browser needs both to choose correctly, and omitting sizes makes it assume the image is full-viewport-width.
Do I need 3× images for high-density screens?
Rarely. Most sites stop at 2×, because file size grows with the square of the scale factor while the perceptible improvement past 2× is small. A 2× asset on a 3× display still looks good.