EditSafely

Generate Sprite Sheet CSS Grid Code

Write CSS that plays a multi-row sprite sheet as an animation and names every frame.

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

Generate Sprite Sheet CSS Grid 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 Generate Sprite Sheet CSS Grid Code

  1. 1. Add the sprite sheet. Drop in a PNG whose frames sit on an even grid, such as a walk cycle or an explosion. A single row of square frames is detected on its own.
  2. 2. Describe the grid and timing. Enter the columns and rows, how many frames to play if the last row is partly empty, the frames per second, and whether the animation loops.
  3. 3. Copy the CSS. You get a class sized to one frame, a keyframes block that steps through every cell row by row, and a class for each frame so you can also show any single one.

When to use Generate Sprite Sheet CSS Grid Code

Generate Sprite Sheet CSS Grid Code turns a grid-shaped sprite sheet into a CSS animation. A single steps() timing curve only slides along one row, so this writes one keyframe per frame, which plays sheets with several rows correctly.

  • Animating a character with CSS only. A walk cycle exported as a 4 by 2 sheet needs eight background positions in order. The keyframes play it at the frame rate you choose with no script.
  • Showing one pose from the sheet. Sometimes a character just stands still. Add a frame class next to the base class to freeze it on any cell without a separate image.
  • Skipping manual offset math. Large sheets have dozens of frames. Every percentage and pixel offset is calculated from the real image size, so nothing drifts out of place.

Examples

Walk cycle

Input

walk.png, 4 columns × 2 rows, 12 fps

Output

@keyframes with 8 frame positions plus .sprite-frame-1 … 8

About the Generate Sprite Sheet CSS Grid Code tool

Generate Sprite Sheet CSS Grid Code runs as plain JavaScript in your browser tab, with no server behind it. Write CSS that plays a multi-row sprite sheet as an animation and names every frame. Whatever you put in stays on your device from start to finish.

The tool is part of EditSafely's PNG Tools section, 292 single-purpose utilities built around the same idea: open the page, get the result, keep your data to yourself.

You can shape the output with 7 settings, including Columns (0 = auto), Rows (0 = auto), Frames to play (0 = every cell) and Frames per second; 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.

That local-first design has practical benefits beyond privacy. The tool keeps working on a flaky connection once the page has loaded, there is no upload to wait for, and it is safe to use with confidential photos and documents.

Frequently asked questions

Is Generate Sprite Sheet CSS Grid Code free to use?

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?

Everything happens locally. Your browser downloads the tool's code once, then does all the processing itself; nothing you enter is transmitted, stored or logged. You can even go offline after the page loads and it will still work.

Which files does Generate Sprite Sheet CSS Grid 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?

No. The tool works in any modern browser on desktop, tablet or phone. There is no account to create, no extension to add and no software to install.

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 →