CSS Sprite Sheet Generator
Combine Images into Sprite Sheets
Combine icons and small images into one sprite sheet PNG, with the CSS classes to show each one. Choose a horizontal, vertical or grid layout; it all happens in your browser, so your images are never uploaded.
Drop your icons here
PNG, SVG, WebP and more, as many as you like. They never leave your device.
A horizontal strip, no padding, plus the CSS. Change it below.
or paste from the clipboard (Ctrl/Cmd+V)
Sprite Settings
Guide by Ashley Whitehair, web designer at Norwich Website Design
How to make a CSS sprite sheet
Add your images
Drop your icons or small images onto the box above, or click it to choose them. Use the arrows beside each image to change the order, which sets its place on the sheet.
Choose a layout
Pick Horizontal, Vertical or Grid, add Padding if you need it, and change the CSS Class Prefix if “sprite” clashes with your own classes. Then press Generate Sprite Sheet.
Download
Press Download ZIP for sprite-sheet.zip, which holds sprite-sheet.png and sprites.css, or Copy CSS to paste the rules straight into your stylesheet.
What a CSS sprite is
A sprite sheet is one image that holds several smaller ones. Each element on your page uses the whole sheet as its background, but is only as big as one image, and background-position slides the sheet so the right image shows through, like a window.
The browser downloads one file instead of one per image, and every image is ready once the sheet has loaded, so a hover state doesn’t flicker while a second file arrives.
When a sprite still makes sense
Sprites date from when every extra request slowed a page down. With HTTP/2 and HTTP/3, browsers fetch many small files over one connection, so saving requests matters much less than it did. For one-colour interface icons, SVG is usually better: it stays sharp at any size and can take its colour from CSS (the SVG Cleaner prepares icons for that). Sprites still suit:
- Game graphics and animation: a horizontal strip of equal-sized frames for a CSS steps() animation, or a grid of tiles.
- Sets of small multi-colour images, such as flags or payment logos, that would otherwise be dozens of tiny files.
- Button states, such as normal and hover, kept in one file so the swap is instant.
Layouts and settings
| Setting | Options | What it does |
|---|---|---|
| Layout | Horizontal (default) | One row, lined up along the top. The sheet is as tall as the tallest image. |
| Layout | Vertical | One column, lined up on the left. The sheet is as wide as the widest image. |
| Layout | Grid | Rows and columns, as close to square as possible: 3 images make 2 columns, 10 make 4. Every cell is the size of the largest image, with each image in its top-left corner. |
| Padding | 0 to 50 px | Transparent space between images, not around the edges. A few pixels stops the edge of a neighbour showing when the page is zoomed. |
| CSS Class Prefix | sprite | The start of every class name. Spaces and other characters that aren’t allowed in a class name become hyphens. |
Images go on the sheet at their own size, never scaled, and the sheet is always a PNG, so transparency is kept. Give an SVG a width and height before adding it; without them, the browser picks a size for it.
Using the CSS
Class names come from the file names: search.png becomes .sprite-search. Letters are made lowercase and anything other than letters, numbers, hyphens and underscores becomes a hyphen, so “Social Icon@2x.png” becomes .sprite-social-icon-2x. If two images end up with the same name, the second gets -1 on the end. This is the CSS for three 32 px icons with 8 px of padding:
/* Sprite Sheet CSS */
.sprite {
background-image: url('sprite-sheet.png');
background-repeat: no-repeat;
display: inline-block;
}
.sprite-home {
width: 32px;
height: 32px;
background-position: -0px -0px;
}
.sprite-search {
width: 32px;
height: 32px;
background-position: -40px -0px;
}
.sprite-cart {
width: 32px;
height: 32px;
background-position: -80px -0px;
}Give each element both classes: the first loads the sheet, the second picks the image. A background image has no alt text, so label icons that carry meaning:
<span class="sprite sprite-search" role="img" aria-label="Search"></span>The url() expects sprite-sheet.png in the same folder as the stylesheet. If you paste the rules into another stylesheet, change it to wherever you upload the image.
Sharp sprites on high-resolution screens
The CSS shows each image at its own pixel size, so on phones and other high-resolution screens it can look soft. For sharp icons, add images at twice the size you’ll show them, then halve every number in the CSS and add a background-size of half the sheet. Three 64 px icons with 16 px of padding make a 224 × 64 sheet, so to show them at 32 px:
.sprite {
background-image: url('sprite-sheet.png');
background-repeat: no-repeat;
background-size: 112px 32px;
display: inline-block;
}
.sprite-home { width: 32px; height: 32px; background-position: 0 0; }
.sprite-search { width: 32px; height: 32px; background-position: -40px 0; }
.sprite-cart { width: 32px; height: 32px; background-position: -80px 0; }Use even sizes and padding, so every halved number is a whole pixel.
Your images never leave your device
The sheet and CSS are made by your browser, on your own device, so your images are never uploaded.
You can check this yourself: open your browser’s developer tools, watch the Network tab and generate a sprite sheet. The only requests are anonymous usage counts, described in our privacy policy.
Frequently asked questions
Is this sprite sheet generator free?
Yes. There’s no sign-up, no watermark and no limit on how many sprite sheets you make.
Are CSS sprites still worth using?
Less than they were. HTTP/2 made many small requests cheap, and SVG icons are usually better for one-colour interface icons. Sprites are still handy for game graphics, animation frames and sets of small multi-colour images.
How do I show one image from the sprite sheet?
Give an element both classes, such as <span class="sprite sprite-home"></span>. The first class loads the sheet and the second sets the size and position of that one image.
How are the class names chosen?
From each file name without its extension, in lowercase, with spaces and symbols turned into hyphens and your prefix in front: “Home Icon.png” becomes .sprite-home-icon. Rename files first for tidier names.
Why can I see the edge of the next image?
Images touch when padding is 0, so zooming or scaling can let a sliver of a neighbour show. Add a few pixels of Padding and generate the sheet again.
Can I make a sprite sheet for a game or animation?
Yes. Make every frame the same size, then use Horizontal for an animation strip or Grid for a tile set. Every image keeps its own size, so the CSS positions match the frames exactly.
How do I make a retina (2x) sprite sheet?
Add images at twice the display size, then halve the widths, heights and positions in the CSS and set background-size to half the sheet’s size. There’s a worked example above.
Which image formats can I use?
PNG, JPG, WebP, GIF, AVIF, BMP, SVG and iPhone HEIC photos. The sheet is always a PNG, so transparent areas stay transparent.
Are my images uploaded to a server?
No. The sprite sheet and CSS are made in your browser, on your device, and never sent anywhere.
Related tools
- SVG OptimizerClean and optimize SVG files for web use. Remove hardcoded colors and dimensions for scalable icons.
- Image TrimmerAutomatically remove excess transparent pixels from PNG, WebP, GIF and AVIF images. Add optional padding and process in bulk.
- Bulk Image ResizerResize images by percentage, exact dimensions, or social media presets. Batch process multiple files while maintaining aspect ratios.
- Image CompressorReduce file size while maintaining visual quality. Set target file sizes or quality percentage for optimal results.
- Base64 EncoderConvert images to Base64 data URIs for embedding in HTML, CSS, or JSON. Eliminate extra HTTP requests.
- Favicon GeneratorGenerate all favicon sizes from one image. Includes ICO, Apple Touch, Android Chrome icons and webmanifest.