How to Pack a Sprite Sheet (Texture Atlas + JSON)
To pack individual sprites into a texture atlas, open the Sprite Sheet Packer, select all your sprite images with Upload Sprites, press Pack the sprites, and save both spritesheet.png and spritesheet.json. The packer arranges sprites edge to edge in rows up to 1024 pixels wide and outputs a JSON Hash map ready for Phaser 3, PixiJS, CSS sprites, or manual slicing in Unity and Godot 4.
Loading forty separate PNG icons or animation frames means forty HTTP requests on the web and repeated texture switches on the GPU. Combining those assets into a single image lets a browser fetch one file and lets a 2D renderer draw many sprites from one texture in memory.
In this guide
- Sprite sheet vs. texture atlas
- Name your frames before packing
- Step 1: Name your files and click Upload Sprites
- Step 2: Press Pack the sprites
- Step 3: Click Download Image and Download JSON
- How the packer lays sprites out
- Loading the atlas in Phaser 3, PixiJS, Unity, Godot 4, and CSS
- Engine quick-reference table
- Common mistakes and how to fix them
- Nothing is uploaded
- Frequently asked questions
- Related tools & guides
Sprite Sheet vs. Texture Atlas
A sprite sheet is one large image that holds multiple smaller images (frames, tiles, or icons) arranged inside a single canvas. Classic character sheets often place every frame inside an identical grid cell, such as 64 by 64 pixels per cell.
A texture atlas goes one step further: it pairs the combined image with a coordinate map (here, a JSON file) listing the exact x, y, w (width), and h (height) rectangle for every named sprite. Because the coordinates are stored explicitly, you can pack a 64 by 96 character next to a 32 by 32 coin and a 128 by 24 health bar without wasting grid space.
Name Your Frames Before Packing
The packer builds each key in the JSON frames object straight from the uploaded file's name. If you upload hero_idle_01.png and coin.png, those exact strings become the frame names you pass to Phaser or PixiJS.
What if you drag files from two folders that happen to share a name, such as two copies of icon.png? The packer tracks names as they load and appends a counter before the file extension on duplicates, turning the second file into icon_2.png (or appending _2 at the end if there is no extension) so nothing is silently overwritten. Even so, giving every file a clear, lowercase name like walk_01.png before you open the tool keeps your game code clean.
Tip before you start: Use PNG files with transparent backgrounds whenever possible. JPG and WebP files also load, and the packed output is always saved as a transparent PNG.
How to Pack a Sprite Sheet in 3 Steps
Step 1Name your files and click Upload Sprites
Open the Sprite Sheet Packer and click Upload Sprites (or drag and drop your images onto the upload box). Select all the sprite images you want in the atlas at once; the tool filters for image files and reports how many loaded.
Step 2Press Pack the sprites
Click Pack the sprites. The tool runs its shelf layout pass, draws every image onto a single canvas, and fills the JSON output box next to the preview. Inspect the preview canvas to confirm none of your sprites are missing.
Step 3Click Download Image and Download JSON
Click Download Image to save spritesheet.png and Download JSON to save spritesheet.json. Place both files in the same directory in your project (such as assets/), because the JSON meta.image field references "spritesheet.png" directly.
Pack your sprites into an atlas
Open Sprite Sheet PackerHow the Packer Lays Sprites Out
Understanding the exact layout rules prevents surprises when you open the sheet in an engine or image editor:
- Tallest-first shelf packing: Before placing anything, the packer sorts all uploaded sprites from tallest to shortest. Grouping tall sprites on early rows keeps wasted vertical space below shorter sprites low.
- 1024-pixel row width: Sprites are placed left to right starting at
x = 0, y = 0. When adding the next sprite would push the current row past1024pixels wide, the packer starts a new row atx = 0below the tallest sprite in the finished row. - Sprites wider than 1024 pixels: If an individual sprite is wider than 1024 px, it starts at
x = 0on its own row and expands the final sheet width to match that sprite's width. - Tight bounding box: The output canvas is sized to the exact width and height of the placed sprites, not padded out to a square or power-of-two texture size.
- No padding, no trimming, no rotation: Sprites are drawn edge to edge at their full source dimensions. Every JSON entry sets
rotated: false,trimmed: false,spriteSourceSizeto{ x: 0, y: 0, w, h }, andsourceSizeto{ w, h }.
Because sprites sit edge to edge with zero gap, linear texture filtering or mipmapping in a game engine can sample a pixel from a neighbouring sprite along a shared border. If you use smooth scaling rather than nearest-neighbour pixel rendering, add a 1 px or 2 px transparent margin inside each source PNG before packing.
Loading the Atlas in Phaser 3, PixiJS, Unity, Godot 4, and CSS
Phaser 3
The exported spritesheet.json uses the JSON Hash format that Phaser's this.load.atlas expects natively. Load both files in preload(), then reference frames by their file names:
function preload() {
this.load.atlas('ui', 'assets/spritesheet.png', 'assets/spritesheet.json');
}
function create() {
this.add.sprite(160, 120, 'ui', 'hero.png');
}
PixiJS
PixiJS reads TexturePacker-style JSON Hash files through its Assets loader. Because meta.image in the JSON already says "spritesheet.png", loading the JSON fetches the PNG from the same folder automatically:
import { Assets, Sprite } from 'pixi.js';
const sheet = await Assets.load('assets/spritesheet.json');
const hero = new Sprite(sheet.textures['hero.png']);
Unity
Unity does not parse TexturePacker JSON Hash files out of the box without a third-party importer or a short custom editor script. You still have two straightforward paths:
- If your sprites have transparent margins around them: Import
spritesheet.png, set Texture Type to Sprite (2D and UI), set Sprite Mode to Multiple, open the Sprite Editor, and run Slice > Automatic. - If your sprites touch edge to edge: Because this packer adds 0 px padding, automatic slicing can merge touching opaque edges into one rectangle. Either slice manually in the Sprite Editor using the
x,y,w, andhnumbers fromspritesheet.json(remembering Unity's Y axis starts from the bottom, sounityY = sheetHeight - y - h), or read the JSON in a Unity editor script.
Godot 4
Godot 4 also does not import generic TexturePacker JSON Hash files without an importer plugin, so slicing is manual unless you write a small editor script. Import spritesheet.png, create an AtlasTexture resource for each frame, assign spritesheet.png as its Atlas, and enter the JSON frame's x, y, w, and h into Region. Attach those AtlasTexture resources to a Sprite2D or a SpriteFrames list on an AnimatedSprite2D. For pixel art, set the CanvasItem texture filter to Nearest so edges stay sharp.
CSS Sprites
On a regular web page, you can turn any frame in spritesheet.json into a CSS class with zero JavaScript. Suppose your JSON contains these two entries:
"hero.png": { "frame": { "x": 0, "y": 0, "w": 64, "h": 96 } }
"star.png": { "frame": { "x": 64, "y": 0, "w": 32, "h": 32 } }
Set each class's width and height to w and h, and set background-position to the negative of x and y so the sheet shifts up and left into the element window:
.sprite {
display: inline-block;
background-image: url('spritesheet.png');
background-repeat: no-repeat;
}
.sprite-hero { width: 64px; height: 96px; background-position: 0 0; }
.sprite-star { width: 32px; height: 32px; background-position: -64px 0; }
Engine Quick-Reference Table
| Engine | What to load | Notes |
|---|---|---|
| Phaser 3 | spritesheet.png + spritesheet.json |
Direct support via this.load.atlas(); frame keys match uploaded filenames. |
| PixiJS | spritesheet.json (with PNG beside it) |
Assets.load() reads meta.image to fetch spritesheet.png automatically. |
| Unity | spritesheet.png |
Does not read the JSON natively; slice in Sprite Editor (Automatic if padded, manual/scripted if touching). |
| Godot 4 | spritesheet.png + JSON coordinates |
Manual AtlasTexture regions using JSON x, y, w, h (or use an importer plugin); set Nearest filter for pixel art. |
| CSS Sprites | spritesheet.png |
Copy w, h, -x, and -y from spritesheet.json into CSS classes. |
Common Mistakes and How to Fix Them
- Sprites bleed into neighbouring frames when scaled: Because the packer places sprites with 0 px spacing, smooth scaling can sample edge pixels from the adjacent sprite. Add 1 px to 2 px of transparent padding around each source sprite before packing, or switch your renderer to nearest-neighbour filtering.
- PixiJS cannot find the PNG after you rename it: If you rename
spritesheet.pngtohero-atlas.png, openspritesheet.jsonand update"image": "spritesheet.png"insidemetato match. - Duplicate frame names get
_2added: Uploading two files namedidle.pngfrom different folders makes the second oneidle_2.png. Rename files cleanly (such ashero_idle.pngandenemy_idle.png) before uploading. - You actually have a sheet or GIF and want individual frames: The packer combines separate images into a sheet. To slice an existing grid sheet into individual PNGs, use the Sprite Sheet Cutter. To turn an animated GIF into a uniform grid sheet with adjustable column count and padding, use the GIF to Sprite Sheet Converter.
Nothing Is Uploaded
The Sprite Sheet Packer reads your image files, runs the shelf-packing algorithm, draws the combined canvas, and generates the JSON file inside your browser tab. Unreleased game art, character animations, and UI kits never leave your device, and you can verify zero network uploads in your browser's DevTools Network tab.
Frequently Asked Questions
What is the difference between a sprite sheet and a texture atlas?
A sprite sheet is the combined image file containing all your smaller graphics. A texture atlas pairs that combined image with a data file (such as JSON) recording the exact x, y, width, and height rectangle for every frame, even when sprites have different dimensions.
How are frame names chosen in the JSON output?
Each frame key in the JSON frames object is taken directly from the uploaded file name, such as hero.png. If you upload two files with the same name, the packer appends a counter before the extension (so the second icon.png becomes icon_2.png) to avoid overwriting.
Does the packer add padding, trim transparency, or rotate sprites?
No. Every sprite is placed edge to edge at its full original dimensions with no padding, no trimming of transparent pixels, and no rotation. Every JSON frame has rotated set to false and trimmed set to false.
What happens if one of my sprites is wider than 1024 pixels?
The shelf packer wraps rows at 1024 pixels wide, so a sprite wider than 1024 pixels is placed at the start of its own row and expands the final sheet width to match that sprite.
Can Unity or Godot 4 load spritesheet.json automatically?
Not out of the box without a plugin or custom editor script. For Unity, import spritesheet.png with Sprite Mode set to Multiple and slice in the Sprite Editor; for Godot 4, create AtlasTexture resources using the x, y, w, and h values from spritesheet.json.
Do I need to rename spritesheet.png before loading in Phaser or PixiJS?
Keep the image named spritesheet.png unless you also edit the image field inside the meta block of spritesheet.json. PixiJS uses that field to locate the PNG automatically when you load the JSON.
Related Tools & Guides
- Sprite Sheet Packer - combine individual PNG, JPG, or WebP sprites into one atlas plus JSON.
- Sprite Sheet Cutter - slice an existing uniform sprite sheet into numbered PNG frames and a ZIP.
- GIF to Sprite Sheet Converter - extract frames from an animated GIF into a padded grid sheet and JSON.
- Pixel Art Upscaler - scale pixel sprites cleanly by integer factors before or after packing.
- Developer Image Tools Overview - favicons, sprites, SVGs, and Base64 assets in the browser.