Five checks I run before a sprite sheet ships — in the browser, in five minutes
A broken texture atlas rarely throws an exception. It renders. That is the whole problem: your sprite sheet loads, the animation plays, and one frame is a quarter of the wrong character, or a soldier's helmet is offset b
A broken texture atlas rarely throws an exception. It renders. That is the whole problem: your sprite sheet loads, the animation plays, and one frame is a quarter of the wrong character, or a soldier's helmet is offset by fourteen pixels, or a frame is silently zero-sized so the animation flickers between two poses. By the time an artist reports it, you have already shipped a build to three testers.
Atlas problems are data problems, and data problems are cheap to check if you check them early. I check five things on every atlas before it goes anywhere near a build. The whole pass takes about five minutes, and it runs in a browser tab. No install, no upload, no account.
The five failure modes worth checking
They are ordered by how often they bite me.
1. The JSON is not the shape the runtime expects. There are three shapes in the wild and they are not interchangeable: a frames object keyed by frame name (TexturePacker "hash"), a frames array of objects with a filename field (the array form), and files where frames is a map with null entries that some exporters emit when a frame is empty. If your loader assumes hash and the file is array, you get zero frames and a very unhelpful error much later. Unknown shape should be reported as unknown, not guessed.
2. A frame is referenced but missing, or present but empty. A frame entry with {} is legal JSON and worthless. So is a name in an animation track that has no matching entry.
3. Duplicate frame names. Two entries with the same name is valid JSON. Which one wins depends on the order the parser happens to iterate, which means the bug reproduces on one machine and not another.
4. Zero or negative frame dimensions. This is the one that produces the flicker. The animation samples the frame, gets an empty rectangle, and the sprite pops to the next pose for one tick.
5. A frame rectangle that sits outside the image. Off-by-one math in a packer, or a sheet that was cropped after the JSON was written. The frame "exists", but the pixels do not.
What the file actually looks like
The hash form, which is what most people mean by "atlas JSON":
{
"frames": {
"hero_run_00": {
"frame": { "x": 0, "y": 0, "w": 64, "h": 64 },
"rotated": false,
"trimmed": true
},
"hero_run_01": {
"frame": { "x": 64, "y": 0, "w": 64, "h": 64 }
}
},
"meta": { "image": "hero.png", "size": { "w": 512, "h": 256 } }
}
The array form, same content, different contract:
{
"frames": [
{ "filename": "hero_run_00", "frame": { "x": 0, "y": 0, "w": 64, "h": 64 } },
{ "filename": "hero_run_01", "frame": { "x": 64, "y": 0, "w": 64, "h": 64 } }
],
"meta": { "image": "hero.png", "size": { "w": 512, "h": 256 } }
}
And the one that costs people an afternoon, an entry that parses fine and means nothing:
{
"frames": {
"hero_run_02": {},
"hero_run_03": { "frame": { "x": 0, "y": 0, "w": 0, "h": 64 } },
"hero_run_04": { "frame": { "x": 448, "y": 0, "w": 128, "h": 64 } }
},
"meta": { "image": "hero.png", "size": { "w": 512, "h": 256 } }
}
Three nameable bugs in one file: an empty entry, a zero-width frame, and a frame that starts at x=448 and is 128 wide on a 512-wide sheet, so it runs off the right edge and its pixels are not there.
Why I stopped checking these by hand
Reading JSON by eye works for ten frames and fails at two hundred. Every time I hand-checked, I checked the first twenty carefully and skimmed the rest, which is exactly inverted from what I needed: the frame that breaks is almost never one of the first twenty.
So the check became a tool. It is one self-contained HTML file. You open it, drop the .json on it (or paste it), and it reports the five categories above with the frame names attached, so the output is a list of things to fix rather than a pass or a fail. The file never leaves the tab. There is no server, because the parse and the arithmetic all happen in the page.
Two things I deliberately made it do: report the format it detected, including "unknown" when it cannot tell, because guessing is how the wrong-shape bug survives; and keep the frame name in every message, because "one frame has zero width" is not actionable and "hero_run_03 has zero width" is.
What it does not do
It does not fix anything. It does not repack, does not touch your image file, does not write a corrected JSON. It reads and reports, which is the part that is cheap to automate and expensive to do by eye.
It also cannot tell you that a frame looks wrong. If the rectangle is inside the image and the size is positive, the pixels are somewhere, and only your eyes can say whether the helmet is on the right head. The checks above catch the class of bugs that are invisible to eyes until a build ships.
If you want to run the pass yourself, the browser version is free: Atlas Inspector. And if the same atlas keeps failing in the engine after the JSON is clean, the desktop tool that walks through the engine-side errors is here: the offline fixer that walks the engine-side error.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.