Convert PNG to CSS Sprite Code
Find every sprite in a PNG sheet and write a CSS class with its size and background-position. Runs entirely in your browser, so your data never leaves your device.
Runs on your device, nothing uploaded
Drop an image anywhere on this page
or paste with Ctrl / ⌘ + V ·
Accepts PNG
Your PNG files never leave this tab
Convert PNG to CSS Sprite Code is JavaScript that your browser has already downloaded, and it does the whole job on your own machine. On a normal site, 200 photos straight off a camera means 1.6 GB uploaded, a wait in somebody's queue, and 240 MB downloaded again. Here it means 0 bytes up and 0 bytes down.
- No upload
- No file size limit
- Works offline once loaded
- Nothing stored or logged
How to use Convert PNG to CSS Sprite Code
- 1. Drop in your sprite sheet. Add the PNG that holds your icons or frames. Sprites separated by transparent space are found automatically, whatever their sizes and layout.
- 2. Pick how sprites are found. Keep transparent gaps for packed icon sheets, or switch to a uniform grid and enter the columns and rows. Set the class prefix and the image URL your CSS should load.
- 3. Copy the CSS. You get one base class with the sheet as its background and a numbered class per sprite with its exact width, height and background-position. Paste it into your stylesheet.
When to use Convert PNG to CSS Sprite Code
Convert PNG to CSS Sprite Code measures the sprites in a sheet and writes the CSS that shows each one on its own. It reads the picture in your browser, so the offsets come from the real pixels rather than guesswork.
- Wiring up an icon sheet. A sheet of dozens of icons needs one class per icon. Generate them all at once, then use the classes in your markup with no manual offset math.
- Fewer image requests in a game. Packing small sprites into one PNG cuts down on downloads. The generated classes display each sprite from the single sheet.
- Sheets with uneven sprite sizes. When icons differ in size, a grid does not fit. Gap detection trims every sprite to its own visible pixels and gives it its own dimensions.
Examples
Icon sheet
Input
icons.png with icons separated by transparent space
Output
.sprite-1 { width: 24px; height: 24px; background-position: 0 0; } ...About the Convert PNG to CSS Sprite Code tool
Convert PNG to CSS Sprite Code does its work locally, right in the browser. Find every sprite in a PNG sheet and write a CSS class with its size and background-position. There is no upload step, no queue and no account, and your data never travels over the network.
It belongs to the PNG Tools collection on EditSafely, a set of 292 small, focused PNG utilities that share the same instant, private workspace.
You can shape the output with 6 settings, including Find sprites by, Columns (0 = auto), Rows (0 = auto) and Skip empty cells; the result is redone automatically when you change one. A worked example further down the page shows exactly what the tool produces for a real input.
Running locally also makes the tool fast and dependable: the image is read straight from your device the moment you drop it, there is no server outage that can take it down mid-task, and private pictures stay private.
Frequently asked questions
Does Convert PNG to CSS Sprite Code cost anything?
Yes, it is completely free. All 2,943 tools on EditSafely work without an account, a subscription or usage limits.
Are my files uploaded to a server?
No data leaves your device. The whole tool is JavaScript that runs inside your browser tab, so there is no upload, no server-side processing and no log of what you did. If you disconnect from the internet after the page loads, it keeps working.
Which files does Convert PNG to CSS Sprite Code accept?
It accepts PNG images. There is no file size cap imposed by a server; very large files are limited only by your device's memory.
Do I need to sign up or install anything?
Nothing to install and no account needed. Open the page in any up-to-date browser, including on a phone or tablet, and the tool is ready.
How do I use the result?
Click Copy to put it on your clipboard, or Download .txt to save it as a file. Drop another image to start again.
Related tools
All PNG Tools →Generate Sprite Sheet CSS Grid Code
Write CSS that plays a multi-row sprite sheet as an animation and names every frame.
Convert PNG to CSS Box-Shadow Art
Redraw a small PNG with one HTML element and a box-shadow per pixel.
Convert PNG to Base64
Encode a PNG file as a Base64 string you can paste into code.