A sprite sheet generator packs many small pictures into one large image and records where each one sits. A texture atlas, also called a spritesheet or image sprite, is one large image that packs many smaller images together, with each sub-image picked out using coordinates [1]. Games use it for animation frames and websites use it for icons. This sprite sheet generator builds the sheet in your browser and writes the CSS or JSON that points to each picture.
How to use the sprite sheet generator
- Add your pictures. You can add many at once, and reorder them with the arrows.
- Choose the number of columns, or leave 0 for a near-square grid.
- Set the space between pictures in pixels.
- Press Make sprite sheet.
- Download the PNG and copy the CSS or JSON coordinates.
How the layout works
- Every picture sits in an equal cell, as wide as the widest picture and as tall as the tallest.
- Smaller pictures are centred in their cell, so mixed sizes still line up.
- The space you set is added around every cell, including the outer edge.
- With columns left at 0 the grid has the square root of the picture count, rounded up, columns.
- Names for the CSS classes come from the file names, cleaned to lower case letters, digits and hyphens. Duplicates get -2, -3 and so on.
Why sprite sheets are used
Putting many images in one file means fewer requests and less overhead. A texture atlas can reduce disk input and output and context switching, and on the web it cuts the number of image requests needed to show a page [1]. For animations, the frames of a character sit side by side in one image, and the program shows one frame at a time by moving a window over the sheet. Today icons are often SVG, but sprite sheets remain common in games and in older sites.
Worked example
Four pictures: two of 32 × 32 pixels, one of 16 × 32 and one of 32 × 16, with columns on automatic and 2 pixels of space. Four pictures give 2 columns and 2 rows. Each cell is 32 × 32. The sheet is 2 + 2 × (32 + 2) = 70 pixels wide and 70 tall. The second picture, 16 pixels wide, is centred in its cell, so it starts at x = 36 + 8 = 44. Its CSS is a 16 by 32 pixel box with a background position of -44px -2px.
| Picture | Size | x | y |
|---|---|---|---|
| first | 32 × 32 | 2 | 2 |
| second | 16 × 32 | 44 | 2 |
| third | 32 × 16 | 2 | 44 |
| fourth | 32 × 32 | 36 | 36 |
Using the CSS and JSON
The CSS output has a .sprite class that sets the background image, and one class per picture that sets its width, height and background position. Put class="sprite sprite-name" on an element to show that picture. The JSON output lists x, y, width and height for each name and the size of the sheet, which game engines can read. Save the PNG as sprite-sheet.png beside your files, or change the path in the CSS. The PNG itself is made with toBlob [2].
Tips and limits
- Use pictures of similar size to avoid wasted space.
- Add 1 or 2 pixels of space when your pictures are scaled, to avoid edges bleeding into neighbours.
- The sheet is limited by your browser's canvas size, so a sheet longer than 16,000 pixels is refused.
Animation frames
For an animation, add the frames in order, for example run-1 to run-8, and set the columns to the number of frames per row. The program then shows one cell at a time by moving the background position or by cutting the frame from the JSON numbers. Keep all frames the same size so the cells line up and the character does not jump from frame to frame.
Icons for a website
For icons, put them on one sheet and use the CSS classes to show each one. A single image file means one request, which helped older sites load faster. With modern HTTP the benefit is smaller, so use sprites where they make your work simpler rather than for speed alone. The generated CSS uses fixed widths and heights, so it works best when icons are shown at their natural size.
Order and naming
The pictures appear in the order of the list, left to right and top to bottom, so use the arrows to put them in the order you need. Rename your files before you add them if you want clean class names, because the names come from the file names. A file called Hero Idle.PNG becomes hero-idle, and a name that would start with a number gets an s- in front so it is valid in CSS.
Privacy and file limits
Everything happens inside your browser tab. The picture is read from your device, drawn on a canvas and saved back to your device, so nothing is sent to a server and nobody else sees it. Files up to 50 MB are accepted, and very large pictures are refused when they would be too big for your browser to handle. JPG, PNG and WebP are supported.
What next
Use this often? Add Sprite Sheet to your Home screen.
Frequently asked questions
What does a sprite sheet generator do?
It places several pictures in one grid image and writes the position of each picture as CSS or JSON so a page or game can show them from that single file.
What is the difference between a sprite sheet and a texture atlas?
They are usually the same idea: one large image that holds many smaller ones. Texture atlas is the term more common in game engines.
How are the pictures arranged?
In equal cells as big as the largest picture, in the order you set. Smaller pictures are centred in their cell.
How do I use the CSS?
Give an element the classes sprite and sprite-name. It then shows only that picture from the sheet.
Are my pictures uploaded?
No. The sheet is drawn in your browser and the pictures stay on your device.
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.